diff options
Diffstat (limited to 'mammoth/conversion.py')
| -rw-r--r-- | mammoth/conversion.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/mammoth/conversion.py b/mammoth/conversion.py index bdc8687..33f61cc 100644 --- a/mammoth/conversion.py +++ b/mammoth/conversion.py @@ -109,6 +109,10 @@ class _DocumentConverter(documents.element_visitor(args=1)): def visit_run(self, run, context): nodes = lambda: self._visit_all(run.children, context) paths = [] + if run.highlight is not None: + style = self._find_style(Highlight(color=run.highlight), "highlight") + if style is not None: + paths.append(style.html_path) if run.is_small_caps: paths.append(self._find_style_for_run_property("small_caps")) if run.is_all_caps: @@ -354,9 +358,19 @@ class _DocumentConverter(documents.element_visitor(args=1)): return "{0}{1}".format(self._id_prefix, suffix) +@cobble.data +class Highlight: + color = cobble.field() + + def _document_matcher_matches(matcher, element, element_type): if matcher.element_type in ["underline", "strikethrough", "all_caps", "small_caps", "bold", "italic", "comment_reference"]: return matcher.element_type == element_type + elif matcher.element_type == "highlight": + return ( + matcher.element_type == element_type and + (matcher.color is None or matcher.color == element.color) + ) elif matcher.element_type == "break": return ( matcher.element_type == element_type and |
