diff options
author | thatch <devnull@localhost> | 2008-08-14 23:39:04 -0700 |
---|---|---|
committer | thatch <devnull@localhost> | 2008-08-14 23:39:04 -0700 |
commit | 424366452ddc8619e89d3580aefb59e2bfae26b0 (patch) | |
tree | 5e6ebe5fc05e5b573c6e5154bd96621f693025e2 /external/markdown-processor.py | |
parent | e6e3faecd77f18ba8977ea1f8832578d683f5930 (diff) | |
parent | 3e1d51e070744961d57aba8b7b2110e3ecaddacf (diff) | |
download | pygments-424366452ddc8619e89d3580aefb59e2bfae26b0.tar.gz |
Merge Scala support from Krzysiek Goj's branch
Diffstat (limited to 'external/markdown-processor.py')
-rw-r--r-- | external/markdown-processor.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/external/markdown-processor.py b/external/markdown-processor.py index 94d02576..e7c8d6f9 100644 --- a/external/markdown-processor.py +++ b/external/markdown-processor.py @@ -9,8 +9,8 @@ from markdown import Markdown md = Markdown() - md.preprocessors.insert(0, CodeBlockPreprocessor()) - markdown = md.__str__ + md.textPreprocessors.insert(0, CodeBlockPreprocessor()) + html = md.convert(someText) markdown is then a callable that can be passed to the context of a template and used in that template, for example. @@ -40,14 +40,14 @@ INLINESTYLES = False import re -from markdown import Preprocessor +from markdown import TextPreprocessor from pygments import highlight from pygments.formatters import HtmlFormatter from pygments.lexers import get_lexer_by_name, TextLexer -class CodeBlockPreprocessor(Preprocessor): +class CodeBlockPreprocessor(TextPreprocessor): pattern = re.compile( r'\[sourcecode:(.+?)\](.+?)\[/sourcecode\]', re.S) @@ -60,8 +60,8 @@ class CodeBlockPreprocessor(Preprocessor): lexer = get_lexer_by_name(m.group(1)) except ValueError: lexer = TextLexer() - code = highlight(m.group(2), lexer, formatter) - code = code.replace('\n\n', '\n \n') + code = highlight(m.group(2), lexer, self.formatter) + code = code.replace('\n\n', '\n \n').replace('\n', '<br />') return '\n\n<div class="code">%s</div>\n\n' % code return self.pattern.sub( - repl, '\n'.join(lines)).split('\n') + repl, lines)
\ No newline at end of file |