From dbc3dac871616c8549cc3ddce01cd0e98f83c1f6 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 19 Nov 2016 20:02:19 +0000 Subject: Include embedded style map when explicit style map is set --- mammoth/options.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'mammoth/options.py') diff --git a/mammoth/options.py b/mammoth/options.py index ddac3de..d33b7ba 100644 --- a/mammoth/options.py +++ b/mammoth/options.py @@ -2,13 +2,24 @@ from . import style_reader, lists, results def read_options(options): - custom_style_map_result = _read_style_map(options.get("style_map") or "") - include_default_style_map = options.get("include_default_style_map", True) - options["ignore_empty_paragraphs"] = options.get("ignore_empty_paragraphs", True) + custom_style_map_text = options.pop("style_map", "") or "" + embedded_style_map_text = options.pop("embedded_style_map", "") or "" + include_default_style_map = options.pop("include_default_style_map", True) + + read_style_map_result = results.combine([ + _read_style_map(custom_style_map_text), + _read_style_map(embedded_style_map_text), + ]) + + custom_style_map, embedded_style_map = read_style_map_result.value + style_map = custom_style_map + embedded_style_map - options["style_map"] = custom_style_map_result.value + \ - (_default_style_map if include_default_style_map else []) - return custom_style_map_result.map(lambda _: options) + if include_default_style_map: + style_map += _default_style_map + + options["ignore_empty_paragraphs"] = options.get("ignore_empty_paragraphs", True) + options["style_map"] = style_map + return read_style_map_result.map(lambda _: options) def _read_style_map(style_text): -- cgit v1.2.3