From 66c9ef99816708cb1ffedd3ec37e5622bf823c20 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 13 Jun 2024 11:52:30 +0100 Subject: Support style mapping for highlights --- lib/style-reader.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/style-reader.js') 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 ); -- cgit v1.2.3