aboutsummaryrefslogtreecommitdiff
path: root/mammoth/__init__.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-11-19 20:02:19 +0000
committerMichael Williamson <mike@zwobble.org>2016-11-19 20:02:19 +0000
commitdbc3dac871616c8549cc3ddce01cd0e98f83c1f6 (patch)
tree471ff3ef5ad09bd9b04f24068a842c75cd278bd1 /mammoth/__init__.py
parent6b6163f5aebd604e76add5e383f91453f906d3f7 (diff)
Include embedded style map when explicit style map is set
Diffstat (limited to 'mammoth/__init__.py')
-rw-r--r--mammoth/__init__.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/mammoth/__init__.py b/mammoth/__init__.py
index 7735fcf..fe480ec 100644
--- a/mammoth/__init__.py
+++ b/mammoth/__init__.py
@@ -5,6 +5,9 @@ from .docx.style_map import write_style_map, read_style_map
__all__ = ["convert_to_html", "extract_raw_text", "images", "underline"]
+_undefined = object()
+
+
def convert_to_html(*args, **kwargs):
return convert(*args, output_format="html", **kwargs)
@@ -13,11 +16,13 @@ def convert_to_markdown(*args, **kwargs):
return convert(*args, output_format="markdown", **kwargs)
-def convert(fileobj, transform_document=None, id_prefix=None, **kwargs):
+def convert(fileobj, transform_document=None, id_prefix=None, include_embedded_style_map=_undefined, **kwargs):
+ if include_embedded_style_map is _undefined:
+ include_embedded_style_map = True
if transform_document is None:
transform_document = lambda x: x
- if kwargs.get("style_map") is None:
- kwargs["style_map"] = read_style_map(fileobj)
+ if include_embedded_style_map:
+ kwargs["embedded_style_map"] = read_style_map(fileobj)
return options.read_options(kwargs).bind(lambda convert_options:
docx.read(fileobj).map(transform_document).bind(lambda document:
conversion.convert_document_element_to_html(