HTML > ODT starts to work
This commit is contained in:
parent
99cb204ca0
commit
9d94cda03f
1 changed files with 14 additions and 7 deletions
21
secretary.py
21
secretary.py
|
|
@ -254,8 +254,10 @@ def markdown_filter(markdown_text):
|
||||||
Convert a markdown text into a ODT formated text
|
Convert a markdown text into a ODT formated text
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from copy import deepcopy, copy
|
||||||
|
from xml.dom import Node
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from copy import deepcopy
|
|
||||||
from markdown2 import markdown
|
from markdown2 import markdown
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise SecretaryError('Could not import markdown2 library. Install it using "pip install markdown2"')
|
raise SecretaryError('Could not import markdown2 library. Install it using "pip install markdown2"')
|
||||||
|
|
@ -272,6 +274,11 @@ def markdown_filter(markdown_text):
|
||||||
'strong': {
|
'strong': {
|
||||||
'replace_with': 'text:span',
|
'replace_with': 'text:span',
|
||||||
'attributes': {}
|
'attributes': {}
|
||||||
|
},
|
||||||
|
|
||||||
|
'i': {
|
||||||
|
'replace_with': 'text:span',
|
||||||
|
'attributes': {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -288,16 +295,16 @@ def markdown_filter(markdown_text):
|
||||||
|
|
||||||
# Transfer child nodes
|
# Transfer child nodes
|
||||||
if html_node.hasChildNodes():
|
if html_node.hasChildNodes():
|
||||||
|
|
||||||
for child_node in html_node.childNodes:
|
for child_node in html_node.childNodes:
|
||||||
odt_node.appendChild(deepcopy(child_node))
|
|
||||||
|
if child_node.nodeType == Node.ELEMENT_NODE:
|
||||||
|
odt_node.appendChild(child_node.cloneNode(True))
|
||||||
|
else:
|
||||||
|
odt_node.appendChild(deepcopy(child_node))
|
||||||
|
|
||||||
html_node.parentNode.replaceChild(odt_node, html_node)
|
html_node.parentNode.replaceChild(odt_node, html_node)
|
||||||
|
|
||||||
return xml_object.toxml()
|
return xml_object.firstChild.toxml()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def render_template(template, **kwargs):
|
def render_template(template, **kwargs):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue