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

Side by Side Diff: cms/converters.py

Issue 6274620759998464: Issue 2450 - [cms] Extra semicolons being added to translatable strings (Closed)
Patch Set: More generic regexp Created May 5, 2015, 2:25 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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"&(?!\S+;)", "&", text)
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld