Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: cms/converters.py

Issue 29947567: Issue 5333 - Ensure links in metadata and in most tags can be made relative (Closed) Base URL: https://hg.adblockplus.org/cms/
Left Patch Set: Address comments on PS1 Created Nov. 21, 2018, 4:29 a.m.
Right Patch Set: Combine regex in converters.py Created Jan. 7, 2019, 10:23 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | tests/expected_output/relative/de/rel_path » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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'(<[\w]+\s[^<>]*\b(href)=\")([^<>\"]+)(\")', 329 text = re.sub(r'(<[\w]+\s[^<>]*\b(href|src)=\")([^<>\"]+)(\")',
330 process_link, text)
331 text = re.sub(r'(<[\w]+\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
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 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld