diff options
Diffstat (limited to 'mammoth/style_reader.py')
| -rw-r--r-- | mammoth/style_reader.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/mammoth/style_reader.py b/mammoth/style_reader.py index 18c848d..0c27bd8 100644 --- a/mammoth/style_reader.py +++ b/mammoth/style_reader.py @@ -1,5 +1,22 @@ +from parsimonious.grammar import Grammar + from . import html_paths def read_html_path(string): - return html_paths.path([html_paths.element(string)]) + root_node = _grammar.parse(string) + tag_names = [root_node.children[0].text] + + for choice_node in root_node.children[1].children: + tag_names.append(choice_node.children[1].text) + + return html_paths.path([html_paths.element(tag_names)]) + + +_grammar = Grammar(""" + +tag_names = identifier ("|" identifier)* + +identifier = ~"[A-Z0-9]*"i + +""") |
