summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-07-03 13:45:36 +0100
committerMichael Williamson <mike@zwobble.org>2016-07-03 13:45:36 +0100
commited8acdfd79b014fd002890361593a9b2c1f21534 (patch)
tree5639f30308ccb86bfb684a2256f22caef2f1aa5f
parent75ad64ef27d5b8fbfa1a54a94c063e69b2c1ce81 (diff)
Add comment reference document matcher
-rw-r--r--mammoth/document_matchers.py4
-rw-r--r--mammoth/style_reader/document_matcher_reader.py6
-rw-r--r--tests/style_reader_tests.py7
3 files changed, 16 insertions, 1 deletions
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():