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/html_path_reader.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'mammoth/style_reader/html_path_reader.py') diff --git a/mammoth/style_reader/html_path_reader.py b/mammoth/style_reader/html_path_reader.py index 0de6e8c..0f1331b 100644 --- a/mammoth/style_reader/html_path_reader.py +++ b/mammoth/style_reader/html_path_reader.py @@ -5,11 +5,10 @@ from .. import html_paths def read_html_path(string): path_node = _grammar.parse(string) - return _read_path_node(path_node) - + return read_html_path_node(path_node) -def _read_path_node(path_node): +def read_html_path_node(path_node): elements = [ _read_element_node(child) for child in _repeated_children_with_separator(path_node, has_whitespace=True) @@ -59,9 +58,9 @@ def _repeated_children_with_separator(node, has_whitespace): yield child.children[sequence_node_index] -_grammar = Grammar(r""" +grammar_text = r""" -path = element whitespace* (">" whitespace* element)* +html_path = element whitespace* (">" whitespace* element)* element = tag_names class_name* fresh? @@ -75,5 +74,7 @@ identifier = ~"[A-Z0-9]*"i whitespace = ~"\s"* -""") +""" + +_grammar = Grammar(grammar_text) -- cgit v1.2.3