summaryrefslogtreecommitdiff
path: root/external/markdown-processor.py
diff options
context:
space:
mode:
authorthatch <devnull@localhost>2008-08-14 23:39:04 -0700
committerthatch <devnull@localhost>2008-08-14 23:39:04 -0700
commit424366452ddc8619e89d3580aefb59e2bfae26b0 (patch)
tree5e6ebe5fc05e5b573c6e5154bd96621f693025e2 /external/markdown-processor.py
parente6e3faecd77f18ba8977ea1f8832578d683f5930 (diff)
parent3e1d51e070744961d57aba8b7b2110e3ecaddacf (diff)
downloadpygments-424366452ddc8619e89d3580aefb59e2bfae26b0.tar.gz
Merge Scala support from Krzysiek Goj's branch
Diffstat (limited to 'external/markdown-processor.py')
-rw-r--r--external/markdown-processor.py14
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&nbsp;\n')
+ code = highlight(m.group(2), lexer, self.formatter)
+ code = code.replace('\n\n', '\n&nbsp;\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