src/cm/utils/comment_positioning.py
changeset 533 c7aed0340a00
parent 519 e89c25780e6e
equal deleted inserted replaced
532:0bad3613f59d 533:c7aed0340a00
     4 import sys, operator
     4 import sys, operator
     5 from cm.utils.spannifier import spannify
     5 from cm.utils.spannifier import spannify
     6 from cm.converters.pandoc_converters import pandoc_convert
     6 from cm.converters.pandoc_converters import pandoc_convert
     7 import logging
     7 import logging
     8 from cm.utils.spannifier import get_the_soup
     8 from cm.utils.spannifier import get_the_soup
       
     9 import re
     9 
    10 
    10 import html5lib
    11 import html5lib
    11 from html5lib import treebuilders
    12 from html5lib import treebuilders
    12 
    13 
    13 def compute_new_comment_positions(old_content, old_format, new_content, new_format, commentList):
    14 def compute_new_comment_positions(old_content, old_format, new_content, new_format, commentList):
   178         else : # the whole content is to be colored with start_color
   179         else : # the whole content is to be colored with start_color
   179             spans += add_marker(content, start_color, [], [], with_markers, with_colors)
   180             spans += add_marker(content, start_color, [], [], with_markers, with_colors)
   180 
   181 
   181         content.replaceWith(spans)
   182         content.replaceWith(spans)
   182 
   183 
   183     return unicode(html)
   184     output = unicode(html)
       
   185     # Soup has introduced HTML entities, which should be expanded
       
   186     output =re.sub(r""", '"', output)
       
   187     output =re.sub(r"&", '&', output)
       
   188     output =re.sub(r">", '>', output)
       
   189     output =re.sub(r"&lt;", '<', output)
       
   190     return unicode(output)