diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-01-07 22:55:43 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-01-07 22:55:43 +0000 |
| commit | 86e37ffa1500a444b59d9ae951f4bfa0bff69caf (patch) | |
| tree | 105df143bcb0323c7fb8b32c18c43ff83eeb7174 | |
| parent | 189b6180fc032c95e49023879fcf328795b45bd3 (diff) | |
Include default style map when using custom style map
| -rw-r--r-- | mammoth/options.py | 7 | ||||
| -rw-r--r-- | tests/options_tests.py | 18 |
2 files changed, 20 insertions, 5 deletions
diff --git a/mammoth/options.py b/mammoth/options.py index 4e4d5f1..a2e32b7 100644 --- a/mammoth/options.py +++ b/mammoth/options.py @@ -2,12 +2,9 @@ from . import style_reader, lists def read_options(options): - if options.get("style_map") is None: - style_map = _default_style_map - else: - style_map = _read_style_map(style_map) + custom_style_map = _read_style_map(options.get("style_map") or "") - options["style_map"] = style_map + options["style_map"] = custom_style_map + _default_style_map return options diff --git a/tests/options_tests.py b/tests/options_tests.py new file mode 100644 index 0000000..c646b12 --- /dev/null +++ b/tests/options_tests.py @@ -0,0 +1,18 @@ +from nose.tools import istest, assert_equal + +from mammoth import style_reader +from mammoth.options import read_options, _default_style_map + + +@istest +def default_style_map_is_used_if_style_map_is_not_set(): + assert_equal(_default_style_map, read_options({})["style_map"]) + + +@istest +def custom_style_mappings_are_prepended_to_default_style_mappings(): + style_map = read_options({ + "style_map": "p.SectionTitle => h2" + })["style_map"] + assert_equal(style_reader.read_style("p.SectionTitle => h2"), style_map[0]) + assert_equal(_default_style_map, style_map[1:]) |
