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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 self._whitelist = whitelist | 52 self._whitelist = whitelist |
53 | 53 |
54 def parse(self, text, pagename): | 54 def parse(self, text, pagename): |
55 self.reset() | 55 self.reset() |
56 self._string = [] | 56 self._string = [] |
57 self._fixed_strings = [] | 57 self._fixed_strings = [] |
58 self._inside_fixed = False | 58 self._inside_fixed = False |
59 self._attrs = {} | 59 self._attrs = {} |
60 self._pagename = pagename | 60 self._pagename = pagename |
61 | 61 |
62 # Force-escape ampersands, otherwise the parser will autocomplete bogus | |
63 # entities. | |
64 text = re.sub(r"&(?!\w+;)", "&", text) | |
Sebastian Noack
2015/05/04 20:45:33
What's about hexadecimal escapes (e.g. ©). \w
Wladimir Palant
2015/05/05 14:26:14
Done.
| |
65 | |
62 try: | 66 try: |
63 self.feed(text) | 67 self.feed(text) |
64 return "".join(self._string), self._attrs, ["".join(s) for s in self._fixe d_strings] | 68 return "".join(self._string), self._attrs, ["".join(s) for s in self._fixe d_strings] |
65 finally: | 69 finally: |
66 self._string = None | 70 self._string = None |
67 self._attrs = None | 71 self._attrs = None |
68 self._pagename = None | 72 self._pagename = None |
69 self._inside_fixed = False | 73 self._inside_fixed = False |
70 self._fixed_strings = None | 74 self._fixed_strings = None |
71 | 75 |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 stack.pop() | 399 stack.pop() |
396 stack[-1]["subitems"].append(item) | 400 stack[-1]["subitems"].append(item) |
397 stack.append(item) | 401 stack.append(item) |
398 return structured | 402 return structured |
399 | 403 |
400 converters = { | 404 converters = { |
401 "html": RawConverter, | 405 "html": RawConverter, |
402 "md": MarkdownConverter, | 406 "md": MarkdownConverter, |
403 "tmpl": TemplateConverter, | 407 "tmpl": TemplateConverter, |
404 } | 408 } |
OLD | NEW |