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

Side by Side Diff: cms/converters.py

Issue 5484402612109312: Issue 2460 - Support <span> tags inside translatable strings (Closed)
Patch Set: Created May 5, 2015, 9:28 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 # HTML escaping is applied when this string is inserted into the document. 103 # HTML escaping is applied when this string is inserted into the document.
104 self._append_text(data) 104 self._append_text(data)
105 105
106 def handle_entityref(self, name): 106 def handle_entityref(self, name):
107 self._append_text(self.unescape("&%s;" % name)) 107 self._append_text(self.unescape("&%s;" % name))
108 108
109 def handle_charref(self, name): 109 def handle_charref(self, name):
110 self._append_text(self.unescape("&#%s;" % name)) 110 self._append_text(self.unescape("&#%s;" % name))
111 111
112 class Converter: 112 class Converter:
113 whitelist = set(["a", "em", "strong", "code"]) 113 whitelist = {"a", "em", "strong", "code", "span"}
114 114
115 def __init__(self, params, key="pagedata"): 115 def __init__(self, params, key="pagedata"):
116 self._params = params 116 self._params = params
117 self._key = key 117 self._key = key
118 self._attribute_parser = AttributeParser(self.whitelist) 118 self._attribute_parser = AttributeParser(self.whitelist)
119 119
120 # Read in any parameters specified at the beginning of the file 120 # Read in any parameters specified at the beginning of the file
121 lines = params[key].splitlines(True) 121 lines = params[key].splitlines(True)
122 while lines and re.search(r"^\s*[\w\-]+\s*=", lines[0]): 122 while lines and re.search(r"^\s*[\w\-]+\s*=", lines[0]):
123 name, value = lines.pop(0).split("=", 1) 123 name, value = lines.pop(0).split("=", 1)
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 stack.pop() 397 stack.pop()
398 stack[-1]["subitems"].append(item) 398 stack[-1]["subitems"].append(item)
399 stack.append(item) 399 stack.append(item)
400 return structured 400 return structured
401 401
402 converters = { 402 converters = {
403 "html": RawConverter, 403 "html": RawConverter,
404 "md": MarkdownConverter, 404 "md": MarkdownConverter,
405 "tmpl": TemplateConverter, 405 "tmpl": TemplateConverter,
406 } 406 }
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