aboutsummaryrefslogtreecommitdiff
path: root/mammoth/styles/parser/style_mapping_parser.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-11-24 22:01:35 +0000
committerMichael Williamson <mike@zwobble.org>2016-11-24 22:01:58 +0000
commit507700470b46329ea8b1f8191e48fa69a24a8deb (patch)
tree035d5c2dcd4560a81067a4b9a7ff28762f06d3c4 /mammoth/styles/parser/style_mapping_parser.py
parent7e3ef0ebd0c3453ce351af70ccdb25e93de1d7a9 (diff)
Add style mapping parser
Diffstat (limited to 'mammoth/styles/parser/style_mapping_parser.py')
-rw-r--r--mammoth/styles/parser/style_mapping_parser.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/mammoth/styles/parser/style_mapping_parser.py b/mammoth/styles/parser/style_mapping_parser.py
new file mode 100644
index 0000000..8c84496
--- /dev/null
+++ b/mammoth/styles/parser/style_mapping_parser.py
@@ -0,0 +1,15 @@
+from .tokeniser import TokenType
+from .document_matcher_parser import parse_document_matcher
+from .html_path_parser import parse_html_path
+from ...styles import Style
+
+
+def parse_style_mapping(tokens):
+ document_matcher = parse_document_matcher(tokens)
+ tokens.skip(TokenType.WHITESPACE)
+ tokens.skip(TokenType.SYMBOL, "=>")
+ tokens.try_skip(TokenType.WHITESPACE)
+ html_path = parse_html_path(tokens)
+ tokens.skip(TokenType.END)
+
+ return Style(document_matcher, html_path)