| OLD | NEW |
| 1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
| 2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
| 3 # | 3 # |
| 4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
| 5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
| 6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
| 7 # | 7 # |
| 8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 ) | 320 ) |
| 321 | 321 |
| 322 def get_html(self, source, filename): | 322 def get_html(self, source, filename): |
| 323 def remove_unnecessary_entities(match): | 323 def remove_unnecessary_entities(match): |
| 324 char = unichr(int(match.group(1))) | 324 char = unichr(int(match.group(1))) |
| 325 if char in html_escapes: | 325 if char in html_escapes: |
| 326 return match.group(0) | 326 return match.group(0) |
| 327 return char | 327 return char |
| 328 | 328 |
| 329 escapes = {} | 329 escapes = {} |
| 330 md = markdown.Markdown(output='html5', extensions=['extra']) | 330 md = markdown.Markdown(output='html5', extensions=[ |
| 331 'markdown.extensions.extra', |
| 332 ]) |
| 331 for char in md.ESCAPED_CHARS: | 333 for char in md.ESCAPED_CHARS: |
| 332 escapes[char] = '&#{};'.format(str(ord(char))) | 334 escapes[char] = '&#{};'.format(str(ord(char))) |
| 333 for key, value in html_escapes.iteritems(): | 335 for key, value in html_escapes.iteritems(): |
| 334 escapes[key] = value | 336 escapes[key] = value |
| 335 | 337 |
| 336 md.preprocessors['html_block'].markdown_in_raw = True | 338 md.preprocessors['html_block'].markdown_in_raw = True |
| 337 | 339 |
| 338 def to_html(s): | 340 def to_html(s): |
| 339 return re.sub(r'</?p>', '', md.convert(s)) | 341 return re.sub(r'</?p>', '', md.convert(s)) |
| 340 | 342 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 stack[-1]['subitems'].append(item) | 526 stack[-1]['subitems'].append(item) |
| 525 stack.append(item) | 527 stack.append(item) |
| 526 return structured | 528 return structured |
| 527 | 529 |
| 528 | 530 |
| 529 converters = { | 531 converters = { |
| 530 'html': RawConverter, | 532 'html': RawConverter, |
| 531 'md': MarkdownConverter, | 533 'md': MarkdownConverter, |
| 532 'tmpl': TemplateConverter, | 534 'tmpl': TemplateConverter, |
| 533 } | 535 } |
| OLD | NEW |