From ed8acdfd79b014fd002890361593a9b2c1f21534 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 3 Jul 2016 13:45:36 +0100 Subject: Add comment reference document matcher --- mammoth/document_matchers.py | 4 ++++ mammoth/style_reader/document_matcher_reader.py | 6 +++++- tests/style_reader_tests.py | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/mammoth/document_matchers.py b/mammoth/document_matchers.py index 6f40318..2efd73f 100644 --- a/mammoth/document_matchers.py +++ b/mammoth/document_matchers.py @@ -31,3 +31,7 @@ class underline(object): class strikethrough(object): element_type = "strikethrough" + + +class comment_reference(object): + element_type = "comment_reference" diff --git a/mammoth/style_reader/document_matcher_reader.py b/mammoth/style_reader/document_matcher_reader.py index 66f5d19..b22b6a0 100644 --- a/mammoth/style_reader/document_matcher_reader.py +++ b/mammoth/style_reader/document_matcher_reader.py @@ -22,6 +22,8 @@ def read_document_matcher_node(root_node): return document_matchers.underline elif element_node.expr_name == "strikethrough": return document_matchers.strikethrough + elif element_node.expr_name == "comment_reference": + return document_matchers.comment_reference def _read_paragraph_node(paragraph_node): @@ -61,7 +63,7 @@ def _read_list_node(list_node): return None grammar_text = r""" -document_matcher = paragraph / run / underline / strikethrough / bold / italic +document_matcher = paragraph / run / underline / strikethrough / bold / italic / comment_reference underline = "u" @@ -71,6 +73,8 @@ bold = "b" italic = "i" +comment_reference = "comment-reference" + paragraph = "p" style_id? style_name_specifier? list? run = "r" style_id? style_name_specifier? diff --git a/tests/style_reader_tests.py b/tests/style_reader_tests.py index 1f68ac2..fddc75b 100644 --- a/tests/style_reader_tests.py +++ b/tests/style_reader_tests.py @@ -162,6 +162,13 @@ class ReadDocumentMatcherTests(object): read_document_matcher("strike") ) + @istest + def reads_comment_reference(self): + assert_equal( + document_matchers.comment_reference, + read_document_matcher("comment-reference") + ) + @istest def document_matcher_is_mapped_to_html_path_using_fat_arrow(): -- cgit v1.2.3