Index: cms/converters.py |
diff --git a/cms/converters.py b/cms/converters.py |
index 3650dd135ad4097f3b1e49ed55b9e79d591da15d..6dce67a831f20b8fbb2df1700c9acc674852f445 100644 |
--- a/cms/converters.py |
+++ b/cms/converters.py |
@@ -143,10 +143,16 @@ class Converter: |
# Insert attributes |
result = escape(result) |
+ def stringify_attribute((name, value)): |
+ return '%s="%s"' % ( |
+ escape(name), |
+ escape(self.insert_localized_strings(value, escapes)) |
+ ) |
+ |
for tag in self.whitelist: |
saved = saved_attributes.get(tag, []) |
for attrs in saved: |
- attrs = map(lambda (name, value): '%s="%s"' % (escape(name), escape(value)), attrs) |
+ attrs = map(stringify_attribute, attrs) |
result = re.sub( |
r"%s([^<>]*?)%s" % (re_escape("<%s>" % tag), re_escape("</%s>" % tag)), |
r'<%s%s>\1</%s>' % (tag, " " + " ".join(attrs) if attrs else "", tag), |
@@ -169,7 +175,12 @@ class Converter: |
return self.localize_string(name, default, self._params["localedata"], escapes) |
return re.sub( |
- r"\{\{\s*([\w\-]+)(?:\[(.*?)\])?\s+(.*?)\}\}", |
+ r"\{\{\s*" |
+ r"([\w\-]+)" # String ID |
+ r"(?:\[(.*?)\])?" # Optional comment |
+ r"\s+" |
+ r"((?:[^\{]|\{(?!\{)|\{\{(?:[^\}]|\}(?!\}))*?\}\})*?)" # Translatable text |
Wladimir Palant
2015/04/22 13:52:24
Yes, this line isn't very readable now. How about
kzar
2015/04/22 14:46:06
Nice, that looks much better and still seems to wo
|
+ r"\}\}", |
lookup_string, |
text, |
flags=re.S |