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

Side by Side Diff: cms/converters.py

Issue 4695455875203072: Noissue - Fix newline bug in tag attributes (Closed)
Patch Set: Created May 7, 2015, 11:17 a.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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 escape(name), 159 escape(name),
160 escape(self.insert_localized_strings(value, {})) 160 escape(self.insert_localized_strings(value, {}))
161 ) 161 )
162 162
163 for tag in self.whitelist: 163 for tag in self.whitelist:
164 saved = saved_attributes.get(tag, []) 164 saved = saved_attributes.get(tag, [])
165 for attrs in saved: 165 for attrs in saved:
166 attrs = map(stringify_attribute, attrs) 166 attrs = map(stringify_attribute, attrs)
167 result = re.sub( 167 result = re.sub(
168 r"%s([^<>]*?)%s" % (re_escape("<%s>" % tag), re_escape("</%s>" % tag)) , 168 r"%s([^<>]*?)%s" % (re_escape("<%s>" % tag), re_escape("</%s>" % tag)) ,
169 r'<%s%s>\1</%s>' % (tag, " " + " ".join(attrs) if attrs else "", tag), 169 lambda match: r'<%s%s>%s</%s>' % (
Sebastian Noack 2015/05/07 11:24:12 I suppose we use a callback now, to prevent backsl
kzar 2015/05/07 11:25:16 Yep, you got it
170 tag,
171 " " + " ".join(attrs) if attrs else "",
172 match.group(1),
173 tag
174 ),
170 result, 1, flags=re.S 175 result, 1, flags=re.S
171 ) 176 )
172 result = re.sub( 177 result = re.sub(
173 r"%s([^<>]*?)%s" % (re_escape("<%s>" % tag), re_escape("</%s>" % tag)), 178 r"%s([^<>]*?)%s" % (re_escape("<%s>" % tag), re_escape("</%s>" % tag)),
174 r"<%s>\1</%s>" % (tag, tag), 179 r"<%s>\1</%s>" % (tag, tag),
175 result, flags=re.S 180 result, flags=re.S
176 ) 181 )
177 return result 182 return result
178 183
179 def insert_localized_strings(self, text, escapes, to_html=lambda s: s): 184 def insert_localized_strings(self, text, escapes, to_html=lambda s: s):
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 stack.pop() 412 stack.pop()
408 stack[-1]["subitems"].append(item) 413 stack[-1]["subitems"].append(item)
409 stack.append(item) 414 stack.append(item)
410 return structured 415 return structured
411 416
412 converters = { 417 converters = {
413 "html": RawConverter, 418 "html": RawConverter,
414 "md": MarkdownConverter, 419 "md": MarkdownConverter,
415 "tmpl": TemplateConverter, 420 "tmpl": TemplateConverter,
416 } 421 }
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