For some reason, when exporting commented text with background colors, angle brackets for html spans are sometimes returned as entities by soup.
authorgibus
Sat, 14 Sep 2013 10:00:45 +0200
changeset 533 c7aed0340a00
parent 532 0bad3613f59d
child 534 2ee166f109ae
For some reason, when exporting commented text with background colors, angle brackets for html spans are sometimes returned as entities by soup.
src/cm/utils/comment_positioning.py
--- a/src/cm/utils/comment_positioning.py	Wed Sep 11 23:13:01 2013 +0200
+++ b/src/cm/utils/comment_positioning.py	Sat Sep 14 10:00:45 2013 +0200
@@ -6,6 +6,7 @@
 from cm.converters.pandoc_converters import pandoc_convert
 import logging
 from cm.utils.spannifier import get_the_soup
+import re
 
 import html5lib
 from html5lib import treebuilders
@@ -180,4 +181,10 @@
 
         content.replaceWith(spans)
 
-    return unicode(html)
+    output = unicode(html)
+    # Soup has introduced HTML entities, which should be expanded
+    output =re.sub(r""", '"', output)
+    output =re.sub(r"&", '&', output)
+    output =re.sub(r">", '>', output)
+    output =re.sub(r"&lt;", '<', output)
+    return unicode(output)