| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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-2016 Eyeo GmbH | 2 # Copyright (C) 2006-2016 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 include_end_regex = '>' | 272 include_end_regex = '>' |
| 273 | 273 |
| 274 def resolve_includes(self, text): | 274 def resolve_includes(self, text): |
| 275 def resolve_include(match): | 275 def resolve_include(match): |
| 276 name = match.group(1) | 276 name = match.group(1) |
| 277 for format_, converter_class in converters.iteritems(): | 277 for format_, converter_class in converters.iteritems(): |
| 278 if self._params['source'].has_include(name, format_): | 278 if self._params['source'].has_include(name, format_): |
| 279 self._params['includedata'] = ( | 279 self._params['includedata'] = ( |
| 280 self._params['source'].read_include(name, format)) | 280 self._params['source'].read_include(name, format)) |
| 281 | 281 |
| 282 converter = converter_class(self._params, key='includedata' | 282 converter = converter_class(self._params, |
|
Vasily Kuznetsov
2017/03/09 12:33:27
This looks kind of awkward with just the closing p
Jon Sonesen
2017/03/09 14:04:17
Yep, will do
| |
| 283 ) | 283 key='includedata') |
| 284 result = converter() | 284 result = converter() |
| 285 self.missing_translations += converter.missing_translations | 285 self.missing_translations += converter.missing_translations |
| 286 self.total_translations += converter.total_translations | 286 self.total_translations += converter.total_translations |
| 287 return result | 287 return result |
| 288 raise Exception('Failed to resolve include {}' | 288 raise Exception('Failed to resolve include {}' |
| 289 'on page {}'.format(name, self._params['page'])) | 289 'on page {}'.format(name, self._params['page'])) |
| 290 | 290 |
| 291 return re.sub( | 291 return re.sub( |
| 292 r'{}\?\s*include\s+([^\s<>"]+)\s*\?{}'.format( | 292 r'{}\?\s*include\s+([^\s<>"]+)\s*\?{}'.format( |
| 293 self.include_start_regex, | 293 self.include_start_regex, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 stack.pop() | 477 stack.pop() |
| 478 stack[-1]['subitems'].append(item) | 478 stack[-1]['subitems'].append(item) |
| 479 stack.append(item) | 479 stack.append(item) |
| 480 return structured | 480 return structured |
| 481 | 481 |
| 482 converters = { | 482 converters = { |
| 483 'html': RawConverter, | 483 'html': RawConverter, |
| 484 'md': MarkdownConverter, | 484 'md': MarkdownConverter, |
| 485 'tmpl': TemplateConverter, | 485 'tmpl': TemplateConverter, |
| 486 } | 486 } |
| LEFT | RIGHT |