Implement href for links and fix issues with preformated text in markdown filter.

This commit is contained in:
Christopher Ramírez 2013-10-24 11:09:44 -06:00
parent 99be02ad63
commit a0c9478e72
2 changed files with 19 additions and 10 deletions

View file

@ -51,7 +51,8 @@ transform_map = {
'a': { 'a': {
'replace_with': 'text:a', 'replace_with': 'text:a',
'attributes': { 'attributes': {
'xlink:type': 'simple' 'xlink:type': 'simple',
'xlink:href': ''
} }
}, },

View file

@ -358,12 +358,20 @@ class Render(object):
html_node.parentNode.replaceChild(odt_node, html_node) html_node.parentNode.replaceChild(odt_node, html_node)
def node_to_string(node):
result = node.toxml()
result = ''.join(c.toxml() for c in xml_object.getElementsByTagName('html')[0].childNodes) # linebreaks in preformated nodes should be converted to <text:line-break/>
# A double linebreak should be replacece with an empty paragraph if (node.__class__.__name__ != 'Text') and \
result = result.replace('\n\n', '<text:p text:style-name="Standard"/>') (node.getAttribute('text:style-name') == 'Preformatted_20_Text'):
return result result = result.replace('\n', '<text:line-break/>')
# All double linebreak should be replaced with an empty paragraph
return result.replace('\n\n', '<text:p text:style-name="Standard"/>')
return ''.join(node_as_str for node_as_str in map(node_to_string,
xml_object.getElementsByTagName('html')[0].childNodes))
def render_template(template, **kwargs): def render_template(template, **kwargs):
""" """