diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-12-13 18:02:12 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-12-13 18:02:12 +0000 |
| commit | 4d09c8116dbf01487368c16a66ea13f07b3349a3 (patch) | |
| tree | 5d842b3aec7ca18a7a7903a82bd0abafc31ab302 /mammoth/style_reader/document_matcher_reader.py | |
| parent | 49d046acf05be128d404a419ecde05091efa30c1 (diff) | |
Parse styles
Diffstat (limited to 'mammoth/style_reader/document_matcher_reader.py')
| -rw-r--r-- | mammoth/style_reader/document_matcher_reader.py | 12 |
1 files changed, 8 insertions, 4 deletions
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) |
