diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-06-17 15:54:29 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-06-17 15:54:29 +0100 |
| commit | cd2a10d64f6f2a1a42c1a3f0c144a3a521083cd8 (patch) | |
| tree | a251f341d5181ef347636e4d5ab3657782d8367b /mammoth/conversion.py | |
| parent | 3bfa77d64e69d20609c8321a067bfa2651a7eabc (diff) | |
Allow strikethrough to be configured in style mapping
Diffstat (limited to 'mammoth/conversion.py')
| -rw-r--r-- | mammoth/conversion.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/mammoth/conversion.py b/mammoth/conversion.py index c4631e1..71edaf4 100644 --- a/mammoth/conversion.py +++ b/mammoth/conversion.py @@ -100,7 +100,7 @@ class DocumentConverter(object): if run.is_underline: self._convert_underline(run_generator) if run.is_strikethrough: - run_generator.start("s") + self._convert_strikethrough(run_generator) self._convert_elements_to_html(run.children, run_generator) run_generator.end_all() html_generator.append(run_generator) @@ -111,6 +111,15 @@ class DocumentConverter(object): if style is not None: append_html_path(run_generator, style.html_path) + + def _convert_strikethrough(self, run_generator): + style = self._find_style(None, "strikethrough") + if style is None: + run_generator.start("s") + else: + append_html_path(run_generator, style.html_path) + + def _convert_text(self, text, html_generator): html_generator.text(text.value) @@ -238,8 +247,8 @@ class DocumentConverter(object): def _document_matcher_matches(matcher, element, element_type): - if matcher.element_type == "underline": - return element_type == "underline" + if matcher.element_type in ["underline", "strikethrough"]: + return matcher.element_type == element_type else: return ( matcher.element_type == element_type and ( |
