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

Side by Side Diff: cms/converters.py

Issue 5172705124941824: Issue 2452 - Avoid replacing "\n" with newline in fixed strings (Closed)
Patch Set: Created May 6, 2015, 4 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 # Extract tag attributes from default string 135 # Extract tag attributes from default string
136 default, saved_attributes, fixed_strings = self._attribute_parser.parse(defa ult, self._params["page"]) 136 default, saved_attributes, fixed_strings = self._attribute_parser.parse(defa ult, self._params["page"])
137 137
138 # Get translation 138 # Get translation
139 if self._params["locale"] != self._params["defaultlocale"] and name in local edata: 139 if self._params["locale"] != self._params["defaultlocale"] and name in local edata:
140 result = localedata[name].strip() 140 result = localedata[name].strip()
141 else: 141 else:
142 result = default 142 result = default
143 143
144 # Insert fixed strings 144 # Insert fixed strings
145 for i in range(len(fixed_strings)): 145 for i in range(len(fixed_strings)):
Sebastian Noack 2015/05/06 16:24:30 While on it, mind making this loop a little more P
Sebastian Noack 2015/05/06 16:25:24 Even better: for i, fixed_string in enumerate(f
kzar 2015/05/06 16:30:41 Done.
146 result = re.sub(r"\{%d\}" % (i + 1), fixed_strings[i], result, 1) 146 result = result.replace("{%d}" % (i + 1), fixed_strings[i], 1)
147 147
148 # Insert attributes 148 # Insert attributes
149 result = escape(result) 149 result = escape(result)
150 def stringify_attribute((name, value)): 150 def stringify_attribute((name, value)):
151 return '%s="%s"' % ( 151 return '%s="%s"' % (
152 escape(name), 152 escape(name),
153 escape(self.insert_localized_strings(value, {})) 153 escape(self.insert_localized_strings(value, {}))
154 ) 154 )
155 155
156 for tag in self.whitelist: 156 for tag in self.whitelist:
(...skipping 240 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