aboutsummaryrefslogtreecommitdiff
path: root/mammoth/docx/body_xml.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2017-05-30 11:10:05 +0100
committerMichael Williamson <mike@zwobble.org>2017-05-30 11:10:05 +0100
commitf772284b08698a47430549f18abc6e004ac06fb6 (patch)
tree6b52921e7fc9d228dfef1227bc999344fd4b3253 /mammoth/docx/body_xml.py
parent803e22c8b95faa99aad82a4c9a30aa132f123416 (diff)
Read target frame on hyperlinks
Diffstat (limited to 'mammoth/docx/body_xml.py')
-rw-r--r--mammoth/docx/body_xml.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py
index 49ff431..3e3e027 100644
--- a/mammoth/docx/body_xml.py
+++ b/mammoth/docx/body_xml.py
@@ -297,15 +297,24 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
def hyperlink(element):
relationship_id = element.attributes.get("r:id")
anchor = element.attributes.get("w:anchor")
+ target_frame = element.attributes.get("w:tgtFrame")
children_result = _read_xml_elements(element.children)
+
+ def create(**kwargs):
+ return children_result.map(lambda children: documents.hyperlink(
+ children=children,
+ target_frame=target_frame,
+ **kwargs
+ ))
+
if relationship_id is not None:
href = relationships[relationship_id].target
if anchor is not None:
href = replace_fragment(href, anchor)
- return children_result.map(lambda children: documents.hyperlink(href=href, children=children))
+ return create(href=href)
elif anchor is not None:
- return children_result.map(lambda children: documents.hyperlink(anchor=anchor, children=children))
+ return create(anchor=anchor)
else:
return children_result