Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: cms/converters.py

Issue 29331049: Issue 3354 - Enable extras module for Markdown inside HTML blocks (Closed)
Left Patch Set: Removed redundant attr_list extension, updated README Created Nov. 26, 2015, 1:59 p.m.
Right Patch Set: Add all Markdown extra extensions to hiddenimports list Created Nov. 27, 2015, 9:43 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « README.md ('k') | runserver.spec » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 return match.group(0) 303 return match.group(0)
304 else: 304 else:
305 return char 305 return char
306 306
307 escapes = {} 307 escapes = {}
308 for char in markdown.Markdown.ESCAPED_CHARS: 308 for char in markdown.Markdown.ESCAPED_CHARS:
309 escapes[char] = "&#" + str(ord(char)) + ";" 309 escapes[char] = "&#" + str(ord(char)) + ";"
310 for key, value in html_escapes.iteritems(): 310 for key, value in html_escapes.iteritems():
311 escapes[key] = value 311 escapes[key] = value
312 312
313 md = markdown.Markdown(output="html5", 313 md = markdown.Markdown(output="html5", extensions=["extra"])
314 extensions=["markdown.extensions.extra"])
Sebastian Noack 2015/11/26 14:23:51 Do we actually have to use the long form for "extr
kzar 2015/11/26 14:41:24 No, just tested it and "extra" works fine. Done.
315 md.preprocessors["html_block"].markdown_in_raw = True 314 md.preprocessors["html_block"].markdown_in_raw = True
316 315
317 def to_html(s): 316 def to_html(s):
318 return re.sub(r'</?p>', '', md.convert(s)) 317 return re.sub(r'</?p>', '', md.convert(s))
319 318
320 result = self.insert_localized_strings(source, escapes, to_html) 319 result = self.insert_localized_strings(source, escapes, to_html)
321 result = md.convert(result) 320 result = md.convert(result)
322 result = re.sub(r"&#(\d+);", remove_unnecessary_entities, result) 321 result = re.sub(r"&#(\d+);", remove_unnecessary_entities, result)
323 result = self.process_links(result) 322 result = self.process_links(result)
324 return result 323 return result
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 stack.pop() 437 stack.pop()
439 stack[-1]["subitems"].append(item) 438 stack[-1]["subitems"].append(item)
440 stack.append(item) 439 stack.append(item)
441 return structured 440 return structured
442 441
443 converters = { 442 converters = {
444 "html": RawConverter, 443 "html": RawConverter,
445 "md": MarkdownConverter, 444 "md": MarkdownConverter,
446 "tmpl": TemplateConverter, 445 "tmpl": TemplateConverter,
447 } 446 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld