From 5f30fc93bf33939a8a958448156a37a970381b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Fri, 4 Nov 2016 11:03:50 -0600 Subject: [PATCH] Fix an issue with previous markdown fix. Previous fix was only keeping the last text node found in a list element. --- secretary.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/secretary.py b/secretary.py index 9dd8c46..f3aaa2c 100644 --- a/secretary.py +++ b/secretary.py @@ -719,19 +719,20 @@ class Renderer(object): # Transfer child nodes if html_node.hasChildNodes(): - for child_node in html_node.childNodes: - # We can't directly insert text into a text:list-item - # element. The content of the item most be wrapped inside - # a container like text:p. When there's not a double linebreak - # separating list elements, markdown2 creates
  • elements without - # wraping their contents inside a container. Here we automatically - # create the container if one was not created by markdown2. - if (tag == 'li' and (not child_node.localName)): - container = xml_object.createElement('text:p') - container.appendChild(child_node.cloneNode(True)) - child_node = container + # We can't directly insert text into a text:list-item element. + # The content of the item most be wrapped inside a container + # like text:p. When there's not a double linebreak separating + # list elements, markdown2 creates
  • elements without wraping + # their contents inside a container. Here we automatically create + # the container if one was not created by markdown2. + if (tag=='li' and html_node.childNodes[0].localName <> 'p'): + container = xml_object.createElement('text:p') + odt_node.appendChild(container) + else: + container = odt_node - odt_node.appendChild(child_node.cloneNode(True)) + for child_node in html_node.childNodes: + container.appendChild(child_node.cloneNode(True)) # Add style-attributes defined in transform_map if 'style_attributes' in transform_map[tag]: