diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-11-19 20:02:19 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-11-19 20:02:19 +0000 |
| commit | dbc3dac871616c8549cc3ddce01cd0e98f83c1f6 (patch) | |
| tree | 471ff3ef5ad09bd9b04f24068a842c75cd278bd1 /mammoth/options.py | |
| parent | 6b6163f5aebd604e76add5e383f91453f906d3f7 (diff) | |
Include embedded style map when explicit style map is set
Diffstat (limited to 'mammoth/options.py')
| -rw-r--r-- | mammoth/options.py | 23 |
1 files changed, 17 insertions, 6 deletions
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): |
