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

Side by Side Diff: cms/converters.py

Issue 29331049: Issue 3354 - Enable extras module for Markdown inside HTML blocks (Closed)
Patch Set: Created Nov. 26, 2015, 1:29 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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", extensions=["attr_list"]) 313 md = markdown.Markdown(output="html5",
314 extensions=["attr_list", "markdown.extensions.extra"] )
saroyanm 2015/11/26 13:49:50 According to documentation extra extension include
kzar 2015/11/26 14:01:34 I read the documentation differently, but I gave i
Sebastian Noack 2015/11/26 14:23:51 Well, this is weird, but seems to be right. While
saroyanm 2015/11/26 14:29:48 Yes I also had a doubt initially, they formulated
314 md.preprocessors["html_block"].markdown_in_raw = True 315 md.preprocessors["html_block"].markdown_in_raw = True
315 316
316 def to_html(s): 317 def to_html(s):
317 return re.sub(r'</?p>', '', md.convert(s)) 318 return re.sub(r'</?p>', '', md.convert(s))
318 319
319 result = self.insert_localized_strings(source, escapes, to_html) 320 result = self.insert_localized_strings(source, escapes, to_html)
320 result = md.convert(result) 321 result = md.convert(result)
321 result = re.sub(r"&#(\d+);", remove_unnecessary_entities, result) 322 result = re.sub(r"&#(\d+);", remove_unnecessary_entities, result)
322 result = self.process_links(result) 323 result = self.process_links(result)
323 return result 324 return result
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 stack.pop() 438 stack.pop()
438 stack[-1]["subitems"].append(item) 439 stack[-1]["subitems"].append(item)
439 stack.append(item) 440 stack.append(item)
440 return structured 441 return structured
441 442
442 converters = { 443 converters = {
443 "html": RawConverter, 444 "html": RawConverter,
444 "md": MarkdownConverter, 445 "md": MarkdownConverter,
445 "tmpl": TemplateConverter, 446 "tmpl": TemplateConverter,
446 } 447 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld