aboutsummaryrefslogtreecommitdiff
path: root/lib/style-reader.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2024-06-13 11:52:30 +0100
committerMichael Williamson <mike@zwobble.org>2024-06-13 11:52:30 +0100
commit66c9ef99816708cb1ffedd3ec37e5622bf823c20 (patch)
tree10e640bcda8b6ecd92a7486a9d700366cf40f239 /lib/style-reader.js
parent700e395a3d2a0c9f6526fe7c69a92bd347fa1b88 (diff)
Support style mapping for highlights
Diffstat (limited to 'lib/style-reader.js')
-rw-r--r--lib/style-reader.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/style-reader.js b/lib/style-reader.js
index 38202f9..6305c59 100644
--- a/lib/style-reader.js
+++ b/lib/style-reader.js
@@ -159,6 +159,23 @@ function documentMatcherRule() {
var strikethrough = identifierToConstant("strike", documentMatchers.strikethrough);
var allCaps = identifierToConstant("all-caps", documentMatchers.allCaps);
var smallCaps = identifierToConstant("small-caps", documentMatchers.smallCaps);
+
+ var highlight = sequence(
+ lop.rules.token("identifier", "highlight"),
+ lop.rules.sequence.capture(lop.rules.optional(lop.rules.sequence(
+ lop.rules.tokenOfType("open-square-bracket"),
+ lop.rules.sequence.cut(),
+ lop.rules.token("identifier", "color"),
+ lop.rules.tokenOfType("equals"),
+ lop.rules.sequence.capture(stringRule),
+ lop.rules.tokenOfType("close-square-bracket")
+ ).head()))
+ ).map(function(color) {
+ return documentMatchers.highlight({
+ color: color.valueOrElse(undefined)
+ });
+ });
+
var commentReference = identifierToConstant("comment-reference", documentMatchers.commentReference);
var breakMatcher = sequence(
@@ -191,6 +208,7 @@ function documentMatcherRule() {
strikethrough,
allCaps,
smallCaps,
+ highlight,
commentReference,
breakMatcher
);