diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-02-25 19:07:27 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-02-25 19:07:27 +0000 |
| commit | 3ed30fd8bc749d3c8009b3fd9e8ce125af5ee441 (patch) | |
| tree | 6460c7e1f2e9940a6ef1e84a2626acfd8ae5aff0 /mammoth | |
| parent | 17ba20787c2637c65df0c02c6ffbd71a318e451a (diff) | |
Read italic document matcher
Diffstat (limited to 'mammoth')
| -rw-r--r-- | mammoth/document_matchers.py | 12 | ||||
| -rw-r--r-- | mammoth/style_reader/document_matcher_reader.py | 10 |
2 files changed, 15 insertions, 7 deletions
diff --git a/mammoth/document_matchers.py b/mammoth/document_matchers.py index 1116a07..6f40318 100644 --- a/mammoth/document_matchers.py +++ b/mammoth/document_matchers.py @@ -17,13 +17,17 @@ RunMatcher = collections.namedtuple("RunMatcher", ["style_id", "style_name"]) RunMatcher.element_type = "run" +class bold(object): + element_type = "bold" + + +class italic(object): + element_type = "italic" + + class underline(object): element_type = "underline" class strikethrough(object): element_type = "strikethrough" - - -class bold(object): - element_type = "bold" diff --git a/mammoth/style_reader/document_matcher_reader.py b/mammoth/style_reader/document_matcher_reader.py index ee5b467..66f5d19 100644 --- a/mammoth/style_reader/document_matcher_reader.py +++ b/mammoth/style_reader/document_matcher_reader.py @@ -14,12 +14,14 @@ def read_document_matcher_node(root_node): return _read_paragraph_node(element_node) elif element_node.expr_name == "run": return _read_run_node(element_node) + elif element_node.expr_name == "bold": + return document_matchers.bold + elif element_node.expr_name == "italic": + return document_matchers.italic elif element_node.expr_name == "underline": return document_matchers.underline elif element_node.expr_name == "strikethrough": return document_matchers.strikethrough - elif element_node.expr_name == "bold": - return document_matchers.bold def _read_paragraph_node(paragraph_node): @@ -59,7 +61,7 @@ def _read_list_node(list_node): return None grammar_text = r""" -document_matcher = paragraph / run / underline / strikethrough / bold +document_matcher = paragraph / run / underline / strikethrough / bold / italic underline = "u" @@ -67,6 +69,8 @@ strikethrough = "strike" bold = "b" +italic = "i" + paragraph = "p" style_id? style_name_specifier? list? run = "r" style_id? style_name_specifier? |
