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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 post += ' hreflang="{}"'\ | 319 post += ' hreflang="{}"'\ |
320 .format(jinja2.Markup.escape(locale)) | 320 .format(jinja2.Markup.escape(locale)) |
321 | 321 |
322 if self._params['relative']: | 322 if self._params['relative']: |
323 current_page = '/{}/{}'.format(self._params['locale'], | 323 current_page = '/{}/{}'.format(self._params['locale'], |
324 self._params['page']) | 324 self._params['page']) |
325 url = make_relative(current_page, url) | 325 url = make_relative(current_page, url) |
326 | 326 |
327 return ''.join((pre, jinja2.Markup.escape(url), post)) | 327 return ''.join((pre, jinja2.Markup.escape(url), post)) |
328 | 328 |
329 text = re.sub(r'(<a\s[^<>]*\b(href)=\")([^<>\"]+)(\")', | 329 text = re.sub(r'(<[\w]+\s[^<>]*\b(href|src)=\")([^<>\"]+)(\")', |
330 process_link, text) | |
331 text = re.sub(r'(<img\s[^<>]*\b(src)=\")([^<>\"]+)(\")', | |
332 process_link, text) | 330 process_link, text) |
333 return text | 331 return text |
334 | 332 |
335 include_start_regex = '<' | 333 include_start_regex = '<' |
336 include_end_regex = '>' | 334 include_end_regex = '>' |
337 | 335 |
338 def resolve_includes(self, text): | 336 def resolve_includes(self, text): |
339 def resolve_include(match): | 337 def resolve_include(match): |
340 name = match.group(1) | 338 name = match.group(1) |
341 for format_, converter_class in converters.iteritems(): | 339 for format_, converter_class in converters.iteritems(): |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 stack[-1]['subitems'].append(item) | 587 stack[-1]['subitems'].append(item) |
590 stack.append(item) | 588 stack.append(item) |
591 return structured | 589 return structured |
592 | 590 |
593 | 591 |
594 converters = { | 592 converters = { |
595 'html': RawConverter, | 593 'html': RawConverter, |
596 'md': MarkdownConverter, | 594 'md': MarkdownConverter, |
597 'tmpl': TemplateConverter, | 595 'tmpl': TemplateConverter, |
598 } | 596 } |
OLD | NEW |