Left: | ||
Right: |
OLD | NEW |
---|---|
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 Loading... | |
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=["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.
| |
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 Loading... | |
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 } |
OLD | NEW |