Implemented <a> tag with support to href attribute.
This commit is contained in:
parent
b8c5232dea
commit
99be02ad63
2 changed files with 13 additions and 3 deletions
|
|
@ -51,8 +51,7 @@ transform_map = {
|
||||||
'a': {
|
'a': {
|
||||||
'replace_with': 'text:a',
|
'replace_with': 'text:a',
|
||||||
'attributes': {
|
'attributes': {
|
||||||
'xlink:type': 'simple',
|
'xlink:type': 'simple'
|
||||||
'xlink:href': ''
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
13
secretary.py
13
secretary.py
|
|
@ -327,11 +327,22 @@ class Render(object):
|
||||||
for child_node in html_node.childNodes:
|
for child_node in html_node.childNodes:
|
||||||
odt_node.appendChild(child_node.cloneNode(True))
|
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]:
|
if 'style_attributes' in transform_map[tag]:
|
||||||
for k, v in transform_map[tag]['style_attributes'].iteritems():
|
for k, v in transform_map[tag]['style_attributes'].iteritems():
|
||||||
odt_node.setAttribute('text:%s' % k, v)
|
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 <a> 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?
|
# Does the node need to create an style?
|
||||||
if 'style' in transform_map[tag]:
|
if 'style' in transform_map[tag]:
|
||||||
name = transform_map[tag]['style']['name']
|
name = transform_map[tag]['style']['name']
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue