aboutsummaryrefslogtreecommitdiff
path: root/mammoth/styles/parser/html_path_parser.py
diff options
context:
space:
mode:
Diffstat (limited to 'mammoth/styles/parser/html_path_parser.py')
-rw-r--r--mammoth/styles/parser/html_path_parser.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/mammoth/styles/parser/html_path_parser.py b/mammoth/styles/parser/html_path_parser.py
index e8f448e..9e155b6 100644
--- a/mammoth/styles/parser/html_path_parser.py
+++ b/mammoth/styles/parser/html_path_parser.py
@@ -1,6 +1,6 @@
from ... import html_paths
from .tokeniser import TokenType
-from .token_parser import parse_identifier, try_parse_class_name
+from .token_parser import parse_identifier, parse_string, try_parse_class_name
def parse_html_path(tokens):
@@ -27,11 +27,13 @@ def _parse_element(tokens):
tag_names = _parse_tag_names(tokens)
class_names = _parse_class_names(tokens)
is_fresh = _parse_is_fresh(tokens)
+ separator = _parse_separator(tokens)
return html_paths.element(
tag_names,
class_names=class_names,
fresh=is_fresh,
+ separator=separator,
)
@@ -62,3 +64,17 @@ def _parse_is_fresh(tokens):
(TokenType.SYMBOL, ":"),
(TokenType.IDENTIFIER, "fresh"),
))
+
+
+def _parse_separator(tokens):
+ is_separator = tokens.try_skip_many((
+ (TokenType.SYMBOL, ":"),
+ (TokenType.IDENTIFIER, "separator"),
+ ))
+ if is_separator:
+ tokens.skip(TokenType.SYMBOL, "(")
+ value = parse_string(tokens)
+ tokens.skip(TokenType.SYMBOL, ")")
+ return value
+ else:
+ return None