OLD | NEW |
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 if link: | 156 if link: |
157 return 'href="%s" hreflang="%s"' % (escape(link), escape(link_locale)) | 157 return 'href="%s" hreflang="%s"' % (escape(link), escape(link_locale)) |
158 return '%s="%s"' % (escape(name), escape(value)) | 158 return '%s="%s"' % (escape(name), escape(value)) |
159 | 159 |
160 for tag in self.whitelist: | 160 for tag in self.whitelist: |
161 saved = saved_attributes.get(tag, []) | 161 saved = saved_attributes.get(tag, []) |
162 for attrs in saved: | 162 for attrs in saved: |
163 attrs = map(stringify_attribute, attrs) | 163 attrs = map(stringify_attribute, attrs) |
164 result = re.sub( | 164 result = re.sub( |
165 r"%s([^<>]*?)%s" % (re_escape("<%s>" % tag), re_escape("</%s>" % tag))
, | 165 r"%s([^<>]*?)%s" % (re_escape("<%s>" % tag), re_escape("</%s>" % tag))
, |
166 r'<%s %s>\1</%s>' % (tag, " ".join(attrs), tag), | 166 r'<%s%s>\1</%s>' % (tag, " " + " ".join(attrs) if attrs else "", tag), |
167 result, 1, flags=re.S | 167 result, 1, flags=re.S |
168 ) | 168 ) |
169 result = re.sub( | 169 result = re.sub( |
170 r"%s([^<>]*?)%s" % (re_escape("<%s>" % tag), re_escape("</%s>" % tag)), | 170 r"%s([^<>]*?)%s" % (re_escape("<%s>" % tag), re_escape("</%s>" % tag)), |
171 r"<%s>\1</%s>" % (tag, tag), | 171 r"<%s>\1</%s>" % (tag, tag), |
172 result, flags=re.S | 172 result, flags=re.S |
173 ) | 173 ) |
174 return result | 174 return result |
175 | 175 |
176 def insert_localized_strings(self, text, escapes, to_html=lambda s: s): | 176 def insert_localized_strings(self, text, escapes, to_html=lambda s: s): |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 stack.pop() | 396 stack.pop() |
397 stack[-1]["subitems"].append(item) | 397 stack[-1]["subitems"].append(item) |
398 stack.append(item) | 398 stack.append(item) |
399 return structured | 399 return structured |
400 | 400 |
401 converters = { | 401 converters = { |
402 "html": RawConverter, | 402 "html": RawConverter, |
403 "md": MarkdownConverter, | 403 "md": MarkdownConverter, |
404 "tmpl": TemplateConverter, | 404 "tmpl": TemplateConverter, |
405 } | 405 } |
OLD | NEW |