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", extensions=["extra"]) |
314 md.preprocessors["html_block"].markdown_in_raw = True | 314 md.preprocessors["html_block"].markdown_in_raw = True |
315 | 315 |
316 def to_html(s): | 316 def to_html(s): |
317 return re.sub(r'</?p>', '', md.convert(s)) | 317 return re.sub(r'</?p>', '', md.convert(s)) |
318 | 318 |
319 result = self.insert_localized_strings(source, escapes, to_html) | 319 result = self.insert_localized_strings(source, escapes, to_html) |
320 result = md.convert(result) | 320 result = md.convert(result) |
321 result = re.sub(r"&#(\d+);", remove_unnecessary_entities, result) | 321 result = re.sub(r"&#(\d+);", remove_unnecessary_entities, result) |
322 result = self.process_links(result) | 322 result = self.process_links(result) |
323 return result | 323 return result |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 stack.pop() | 437 stack.pop() |
438 stack[-1]["subitems"].append(item) | 438 stack[-1]["subitems"].append(item) |
439 stack.append(item) | 439 stack.append(item) |
440 return structured | 440 return structured |
441 | 441 |
442 converters = { | 442 converters = { |
443 "html": RawConverter, | 443 "html": RawConverter, |
444 "md": MarkdownConverter, | 444 "md": MarkdownConverter, |
445 "tmpl": TemplateConverter, | 445 "tmpl": TemplateConverter, |
446 } | 446 } |
OLD | NEW |