From 99be02ad6365cbd899541b56d8aa789b519de2db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Thu, 12 Sep 2013 18:24:40 -0600 Subject: [PATCH] Implemented tag with support to href attribute. --- markdown_map.py | 3 +-- secretary.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/markdown_map.py b/markdown_map.py index 5e480e9..c09ce68 100644 --- a/markdown_map.py +++ b/markdown_map.py @@ -51,8 +51,7 @@ transform_map = { 'a': { 'replace_with': 'text:a', 'attributes': { - 'xlink:type': 'simple', - 'xlink:href': '' + 'xlink:type': 'simple' } }, diff --git a/secretary.py b/secretary.py index 99c94f0..8568538 100644 --- a/secretary.py +++ b/secretary.py @@ -327,11 +327,22 @@ class Render(object): for child_node in html_node.childNodes: odt_node.appendChild(child_node.cloneNode(True)) - # Add style attributes defined in transform_map + # Add style-attributes defined in transform_map if 'style_attributes' in transform_map[tag]: for k, v in transform_map[tag]['style_attributes'].iteritems(): odt_node.setAttribute('text:%s' % k, v) + # Add defined attributes + if 'attributes' in transform_map[tag]: + for k, v in transform_map[tag]['attributes'].iteritems(): + odt_node.setAttribute(k, v) + + # copy original href attribute in tag + if tag == 'a': + if html_node.hasAttribute('href'): + odt_node.setAttribute('xlink:href', + html_node.getAttribute('href')) + # Does the node need to create an style? if 'style' in transform_map[tag]: name = transform_map[tag]['style']['name']