| 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 16 matching lines...) Expand all Loading... |
| 27 # Monkey-patch Markdown's isBlockLevel function to ensure that no paragraphs | 27 # Monkey-patch Markdown's isBlockLevel function to ensure that no paragraphs |
| 28 # are inserted into the <head> tag | 28 # are inserted into the <head> tag |
| 29 orig_isBlockLevel = markdown.util.isBlockLevel | 29 orig_isBlockLevel = markdown.util.isBlockLevel |
| 30 | 30 |
| 31 | 31 |
| 32 def isBlockLevel(tag): | 32 def isBlockLevel(tag): |
| 33 if tag == 'head': | 33 if tag == 'head': |
| 34 return True | 34 return True |
| 35 return orig_isBlockLevel(tag) | 35 return orig_isBlockLevel(tag) |
| 36 | 36 |
| 37 |
| 37 markdown.util.isBlockLevel = isBlockLevel | 38 markdown.util.isBlockLevel = isBlockLevel |
| 38 | 39 |
| 39 html_escapes = { | 40 html_escapes = { |
| 40 '<': '<', | 41 '<': '<', |
| 41 '>': '>', | 42 '>': '>', |
| 42 '&': '&', | 43 '&': '&', |
| 43 '"': '"', | 44 '"': '"', |
| 44 "'": ''', | 45 "'": ''', |
| 45 } | 46 } |
| 46 | 47 |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 | 552 |
| 552 structured = [] | 553 structured = [] |
| 553 stack = [{'level': 0, 'subitems': structured}] | 554 stack = [{'level': 0, 'subitems': structured}] |
| 554 for item in flat: | 555 for item in flat: |
| 555 while stack[-1]['level'] >= item['level']: | 556 while stack[-1]['level'] >= item['level']: |
| 556 stack.pop() | 557 stack.pop() |
| 557 stack[-1]['subitems'].append(item) | 558 stack[-1]['subitems'].append(item) |
| 558 stack.append(item) | 559 stack.append(item) |
| 559 return structured | 560 return structured |
| 560 | 561 |
| 562 |
| 561 converters = { | 563 converters = { |
| 562 'html': RawConverter, | 564 'html': RawConverter, |
| 563 'md': MarkdownConverter, | 565 'md': MarkdownConverter, |
| 564 'tmpl': TemplateConverter, | 566 'tmpl': TemplateConverter, |
| 565 } | 567 } |
| OLD | NEW |