From 16041cb9c8a22b1f37473d88050a2e2e9b407f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Thu, 12 Sep 2013 17:28:00 -0600 Subject: [PATCH] replace key attributes for style_attributes in transform_map. --- markdown_map.py | 26 +++++++++++++++----------- secretary.py | 6 +++--- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/markdown_map.py b/markdown_map.py index 92add26..6d4ca1d 100644 --- a/markdown_map.py +++ b/markdown_map.py @@ -3,13 +3,13 @@ # Transform map used by the markdown filter. transform_map have # instructions of how to transform a HTML style tag into a ODT document # styled tag. Some ODT tags may need extra attributes; these are defined -# as a dict in the 'attributes' key. Also, some tags may need to create +# as a dict in the 'style_attributes' key. Also, some tags may need to create # new styles in the document. common_styles = { 'italic': { 'replace_with': 'text:span', - 'attributes': { + 'style_attributes': { 'style-name': 'markdown_italic' }, @@ -25,7 +25,7 @@ common_styles = { 'strong': { 'replace_with': 'text:span', - 'attributes': { + 'style_attributes': { 'style-name': 'markdown_bold' }, @@ -41,13 +41,17 @@ common_styles = { 'p': { 'replace_with': 'text:p', - 'attributes': { + 'style_attributes': { 'style-name': 'Standard' } } } transform_map = { + 'a': { + 'replace_with': 'text:a', + }, + 'p': common_styles['p'], 'strong': common_styles['strong'], 'em': common_styles['italic'], @@ -57,42 +61,42 @@ transform_map = { # Heading Styles (Use styles defined in the document) 'h1': { 'replace_with': 'text:p', - 'attributes': { + 'style_attributes': { 'style-name': 'Heading_20_1' } }, 'h2': { 'replace_with': 'text:p', - 'attributes': { + 'style_attributes': { 'style-name': 'Heading_20_2' } }, 'h3': { 'replace_with': 'text:p', - 'attributes': { + 'style_attributes': { 'style-name': 'Heading_20_3' } }, 'h4': { 'replace_with': 'text:p', - 'attributes': { + 'style_attributes': { 'style-name': 'Heading_20_4' } }, - + 'pre': { 'replace_with': 'text:p', - 'attributes': { + 'style_attributes': { 'style-name': 'Preformatted_20_Text' } }, 'code': { 'replace_with': 'text:span', - 'attributes': { + 'style_attributes': { 'style-name': 'Preformatted_20_Text' } }, diff --git a/secretary.py b/secretary.py index a53a6e4..99c94f0 100644 --- a/secretary.py +++ b/secretary.py @@ -327,9 +327,9 @@ class Render(object): for child_node in html_node.childNodes: odt_node.appendChild(child_node.cloneNode(True)) - # Add attributes defined in transform_map - if 'attributes' in transform_map[tag]: - for k, v in transform_map[tag]['attributes'].iteritems(): + # 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) # Does the node need to create an style?