diff -r 5cd02f32be5e -r 8ec189cc214d src/cm/utils/spannifier.py --- a/src/cm/utils/spannifier.py Mon Mar 18 17:29:40 2013 +0100 +++ b/src/cm/utils/spannifier.py Wed Mar 27 17:51:18 2013 +0100 @@ -7,8 +7,8 @@ def get_text_nodes(soup): return soup(text=lambda text:not isinstance(text, Comment)) -def is_real_text_node(textNode): - if textNode.string == "\n": +def is_real_text_node(textNode, nolinefeed=True): + if nolinefeed and textNode.string == "\n": return False return not textNode.findParent('style') @@ -17,7 +17,7 @@ from cm.utils.cache import memoize, dj_memoize @dj_memoize -def spannify(input): +def spannify(input, nolinefeed=True): """ wrap textNodes in spans """ @@ -32,7 +32,7 @@ span_starts = {} for i in xrange(len(textNodes)): textNode = textNodes[i] - if is_real_text_node(textNode) : + if is_real_text_node(textNode, nolinefeed) : textNode.replaceWith('' + textNode.string + '') span_starts[i] = len(''.join(textNodes_content)) textNodes_content.append(textNode.string)