Trying code for attributes.

This commit is contained in:
Christopher Ramírez 2013-09-12 12:41:02 -06:00
parent 3a0aca3b7b
commit 605e980c21

View file

@ -256,17 +256,41 @@ def markdown_filter(markdown_text):
replacement_map = { replacement_map = {
'p': { 'p': {
'replace_with': 'text:p', 'replace_with': 'text:p',
'attributes': {} 'attributes': {
'style-name': 'Standard'
}
}, },
'strong': { 'strong': {
'replace_with': 'text:span', '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': { 'i': {
'replace_with': 'text:span', '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: else:
odt_node.appendChild(deepcopy(child_node)) 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) html_node.parentNode.replaceChild(odt_node, html_node)
return xml_object.firstChild.toxml() return xml_object.firstChild.toxml()