replace key attributes for style_attributes in transform_map.
This commit is contained in:
parent
aab74d3ef2
commit
16041cb9c8
2 changed files with 18 additions and 14 deletions
|
|
@ -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'
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue