allura
リビジョン | 0f78e6d8f1502ba9351f79022afbc78e9be56f59 (tree) |
---|---|
日時 | 2010-10-28 06:56:50 |
作者 | Rick Copeland <rcopeland@geek...> |
コミッター | Rick Copeland |
[#1088] - mark all markdown-converted text as safe for jinja
@@ -17,6 +17,7 @@ import markdown | ||
17 | 17 | import feedparser |
18 | 18 | |
19 | 19 | from . import macro |
20 | +from . import helpers as h | |
20 | 21 | |
21 | 22 | log = logging.getLogger(__name__) |
22 | 23 |
@@ -38,6 +39,7 @@ class ForgeExtension(markdown.Extension): | ||
38 | 39 | # Rewrite all relative links that don't start with . to have a '../' prefix |
39 | 40 | md.postprocessors['rewrite_relative_links'] = RelativeLinkRewriter( |
40 | 41 | make_absolute=self._is_email) |
42 | + md.postprocessors['mark_safe'] = MarkAsSafe() | |
41 | 43 | |
42 | 44 | def reset(self): |
43 | 45 | self.forge_processor.reset() |
@@ -196,6 +198,11 @@ class ForgeTreeProcessor(markdown.treeprocessors.Treeprocessor): | ||
196 | 198 | node.attrib['class'] = ' '.join(classes) |
197 | 199 | return root |
198 | 200 | |
201 | +class MarkAsSafe(markdown.postprocessors.Postprocessor): | |
202 | + | |
203 | + def run(self, text): | |
204 | + return h.html.literal(text) | |
205 | + | |
199 | 206 | class RelativeLinkRewriter(markdown.postprocessors.Postprocessor): |
200 | 207 | |
201 | 208 | def __init__(self, make_absolute=False): |