Show More
@@ -48,7 +48,7 b' def annotate_highlight(filenode, annotat' | |||||
48 | :param headers: dictionary with headers (keys are whats in ``order`` |
|
48 | :param headers: dictionary with headers (keys are whats in ``order`` | |
49 | parameter) |
|
49 | parameter) | |
50 | """ |
|
50 | """ | |
51 | from kallithea.lib.utils import get_custom_lexer |
|
51 | from kallithea.lib.pygmentsutils import get_custom_lexer | |
52 | options['linenos'] = True |
|
52 | options['linenos'] = True | |
53 | formatter = AnnotateHtmlFormatter(filenode=filenode, order=order, |
|
53 | formatter = AnnotateHtmlFormatter(filenode=filenode, order=order, | |
54 | headers=headers, |
|
54 | headers=headers, |
@@ -41,7 +41,7 b' from webhelpers.html.tags import _set_in' | |||||
41 |
|
41 | |||
42 | from kallithea.config.routing import url |
|
42 | from kallithea.config.routing import url | |
43 | from kallithea.lib.annotate import annotate_highlight |
|
43 | from kallithea.lib.annotate import annotate_highlight | |
44 | from kallithea.lib.utils import get_custom_lexer |
|
44 | from kallithea.lib.pygmentsutils import get_custom_lexer | |
45 | from kallithea.lib.utils2 import str2bool, safe_unicode, safe_str, \ |
|
45 | from kallithea.lib.utils2 import str2bool, safe_unicode, safe_str, \ | |
46 | time_to_datetime, AttributeDict, safe_int, MENTIONS_REGEX |
|
46 | time_to_datetime, AttributeDict, safe_int, MENTIONS_REGEX | |
47 | from kallithea.lib.markup_renderer import url_re |
|
47 | from kallithea.lib.markup_renderer import url_re |
@@ -78,3 +78,15 b' def get_index_filenames():' | |||||
78 | filenames.append(f) |
|
78 | filenames.append(f) | |
79 |
|
79 | |||
80 | return filenames |
|
80 | return filenames | |
|
81 | ||||
|
82 | ||||
|
83 | def get_custom_lexer(extension): | |||
|
84 | """ | |||
|
85 | returns a custom lexer if it's defined in rcextensions module, or None | |||
|
86 | if there's no custom lexer defined | |||
|
87 | """ | |||
|
88 | import kallithea | |||
|
89 | #check if we didn't define this extension as other lexer | |||
|
90 | if kallithea.EXTENSIONS and extension in kallithea.EXTENSIONS.EXTRA_LEXERS: | |||
|
91 | _lexer_name = kallithea.EXTENSIONS.EXTRA_LEXERS[extension] | |||
|
92 | return lexers.get_lexer_by_name(_lexer_name) |
@@ -580,19 +580,6 b' def load_rcextensions(root_path):' | |||||
580 | # setattr(EXT, k, getattr(rcextensions, k)) |
|
580 | # setattr(EXT, k, getattr(rcextensions, k)) | |
581 |
|
581 | |||
582 |
|
582 | |||
583 | def get_custom_lexer(extension): |
|
|||
584 | """ |
|
|||
585 | returns a custom lexer if it's defined in rcextensions module, or None |
|
|||
586 | if there's no custom lexer defined |
|
|||
587 | """ |
|
|||
588 | import kallithea |
|
|||
589 | from pygments import lexers |
|
|||
590 | #check if we didn't define this extension as other lexer |
|
|||
591 | if kallithea.EXTENSIONS and extension in kallithea.EXTENSIONS.EXTRA_LEXERS: |
|
|||
592 | _lexer_name = kallithea.EXTENSIONS.EXTRA_LEXERS[extension] |
|
|||
593 | return lexers.get_lexer_by_name(_lexer_name) |
|
|||
594 |
|
||||
595 |
|
||||
596 | #============================================================================== |
|
583 | #============================================================================== | |
597 | # TEST FUNCTIONS AND CREATORS |
|
584 | # TEST FUNCTIONS AND CREATORS | |
598 | #============================================================================== |
|
585 | #============================================================================== |
General Comments 0
You need to be logged in to leave comments.
Login now