From 4d09c8116dbf01487368c16a66ea13f07b3349a3 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 13 Dec 2013 18:02:12 +0000 Subject: Parse styles --- mammoth/style_reader/document_matcher_reader.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'mammoth/style_reader/document_matcher_reader.py') diff --git a/mammoth/style_reader/document_matcher_reader.py b/mammoth/style_reader/document_matcher_reader.py index 7fc8bcb..fba6092 100644 --- a/mammoth/style_reader/document_matcher_reader.py +++ b/mammoth/style_reader/document_matcher_reader.py @@ -5,6 +5,10 @@ from .. import document_matchers, documents def read_document_matcher(string): root_node = _grammar.parse(string) + return read_document_matcher_node(root_node) + + +def read_document_matcher_node(root_node): element_node = root_node.children[0] if element_node.expr_name == "paragraph": return _read_paragraph_node(element_node) @@ -39,9 +43,8 @@ def _read_list_node(list_node): else: return None - -_grammar = Grammar(r""" -matcher = paragraph / run +grammar_text = r""" +document_matcher = paragraph / run paragraph = "p" style_name? list? @@ -54,5 +57,6 @@ style_identifier = ~"[A-Z0-9]*"i list = ":" list_type "(" ~"[0-9]+" ")" list_type = "ordered-list" / "unordered-list" -""") +""" +_grammar = Grammar(grammar_text) -- cgit v1.2.3