diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-12-12 22:37:04 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-12-12 22:37:04 +0000 |
| commit | dae26433ca6f7211b2eca03d2079c86c2e2dcfc7 (patch) | |
| tree | c38a3b55827b063b2dee2259b2d0dfd9b70a5bda /mammoth/style_reader | |
| parent | 3672775a5469e06455685d74f0f4f0ee35505ff5 (diff) | |
Read document paragraphs with style names
Diffstat (limited to 'mammoth/style_reader')
| -rw-r--r-- | mammoth/style_reader/document_matcher_reader.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/mammoth/style_reader/document_matcher_reader.py b/mammoth/style_reader/document_matcher_reader.py index 583613a..f72f03d 100644 --- a/mammoth/style_reader/document_matcher_reader.py +++ b/mammoth/style_reader/document_matcher_reader.py @@ -10,10 +10,22 @@ def read_document_matcher(string): def _read_paragraph_node(paragraph_node): - return document_matchers.paragraph() + style_name = _read_style_node(paragraph_node.children[1]) + return document_matchers.paragraph(style_name=style_name) + + +def _read_style_node(style_node): + if style_node.children: + return style_node.children[0].children[1].text + else: + return None _grammar = Grammar(r""" -paragraph = "p" +paragraph = "p" style_name? + +style_name = "." style_identifier + +style_identifier = ~"[A-Z0-9]*"i """) |
