From 605e980c219469ec6dab12bfc727a0f03d6a9b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Ram=C3=ADrez?= Date: Thu, 12 Sep 2013 12:41:02 -0600 Subject: [PATCH] Trying code for attributes. --- secretary.py | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/secretary.py b/secretary.py index 098e198..fd326e5 100644 --- a/secretary.py +++ b/secretary.py @@ -256,17 +256,41 @@ def markdown_filter(markdown_text): replacement_map = { 'p': { 'replace_with': 'text:p', - 'attributes': {} + 'attributes': { + 'style-name': 'Standard' + } }, 'strong': { 'replace_with': 'text:span', - 'attributes': {} + 'attributes': { + 'style-name': 'markdown_bold' + }, + + 'style': { + 'create': 'markdown_bold', + 'properties': { + 'fo:font-weight': 'bold', + 'style:font-weight-asian': 'bold', + 'style:font-weight-complex': 'bold' + } + } }, 'i': { 'replace_with': 'text:span', - 'attributes': {} + 'attributes': { + 'style-name': 'markdown_italic' + }, + + 'style': { + 'create': 'markdown_italic', + 'properties': { + 'fo:font-style': 'italic', + 'style:font-style-asian': 'italic', + 'style:font-style-complex': 'italic' + } + } } } @@ -294,6 +318,11 @@ def markdown_filter(markdown_text): else: odt_node.appendChild(deepcopy(child_node)) + # Agregar los atributos definidos en el mapa + if 'attributes' in replacement_map[tag]: + for k, v in replacement_map[tag]['attributes'].iteritems(): + odt_node.setAttribute('text:%s' % k, v) + html_node.parentNode.replaceChild(odt_node, html_node) return xml_object.firstChild.toxml()