aboutsummaryrefslogtreecommitdiff
path: root/mammoth/style_reader.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-12-12 22:22:16 +0000
committerMichael Williamson <mike@zwobble.org>2013-12-12 22:22:16 +0000
commit2791c74b8c1afc1014e380111b7e7f4d4ea09539 (patch)
tree966d0718caa3522eb2477d1f64558ff7085d19a6 /mammoth/style_reader.py
parenteab369b5721b933c080516fd1dcdfa67e6e2dfcd (diff)
Read :fresh on HTML path elements
Diffstat (limited to 'mammoth/style_reader.py')
-rw-r--r--mammoth/style_reader.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/mammoth/style_reader.py b/mammoth/style_reader.py
index 4418dbb..2cdc261 100644
--- a/mammoth/style_reader.py
+++ b/mammoth/style_reader.py
@@ -20,7 +20,8 @@ def _read_path_node(path_node):
def _read_element_node(node):
tag_names = _read_tag_names_node(node.children[0])
class_names = _read_class_names_node(node.children[1])
- return html_paths.element(tag_names, class_names=class_names)
+ fresh = _read_fresh_node(node.children[2])
+ return html_paths.element(tag_names, class_names=class_names, fresh=fresh)
def _read_tag_names_node(node):
@@ -41,6 +42,10 @@ def _read_class_name_node(node):
return node.children[1].text
+def _read_fresh_node(node):
+ return len(node.children) > 0
+
+
def _repeated_children_with_separator(node, has_whitespace):
yield node.children[0]
@@ -58,11 +63,13 @@ _grammar = Grammar(r"""
path = element whitespace* (">" whitespace* element)*
-element = tag_names class_name*
+element = tag_names class_name* fresh?
+
+tag_names = identifier ("|" identifier)*
class_name = "." identifier
-tag_names = identifier ("|" identifier)*
+fresh = ":fresh"
identifier = ~"[A-Z0-9]*"i