aboutsummaryrefslogtreecommitdiff
path: root/mammoth/docx
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2017-11-23 19:54:53 +0000
committerMichael Williamson <mike@zwobble.org>2017-11-23 19:54:53 +0000
commitc6e6a2b462d0bc5b7a5ac61d26c907e66cbcc946 (patch)
tree0ba9641dea203413923a08b44a8e7f56a5ee99f4 /mammoth/docx
parentd44b2df9238e007cfe7bf1becf11b30e1e97d284 (diff)
Parse paragraph indents
Diffstat (limited to 'mammoth/docx')
-rw-r--r--mammoth/docx/body_xml.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/mammoth/docx/body_xml.py b/mammoth/docx/body_xml.py
index 01920f0..cfe3493 100644
--- a/mammoth/docx/body_xml.py
+++ b/mammoth/docx/body_xml.py
@@ -120,6 +120,7 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
properties = element.find_child_or_null("w:pPr")
alignment = properties.find_child_or_null("w:jc").attributes.get("w:val")
numbering = _read_numbering_properties(properties.find_child_or_null("w:numPr"))
+ indent = _read_paragraph_indent(properties.find_child_or_null("w:ind"))
return _ReadResult.map_results(
_read_paragraph_style(properties),
@@ -130,6 +131,7 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
style_name=style[1],
numbering=numbering,
alignment=alignment,
+ indent=indent,
)).append_extra()
def _read_paragraph_style(properties):
@@ -203,6 +205,14 @@ def _create_reader(numbering, content_types, relationships, styles, docx_file, f
else:
return numbering.find_level(num_id, level_index)
+ def _read_paragraph_indent(element):
+ attributes = element.attributes
+ return documents.paragraph_indent(
+ start=attributes.get("w:start") or attributes.get("w:left"),
+ end=attributes.get("w:end") or attributes.get("w:right"),
+ first_line=attributes.get("w:firstLine"),
+ hanging=attributes.get("w:hanging"),
+ )
def tab(element):
return _success(documents.tab())