aboutsummaryrefslogtreecommitdiff
path: root/lib/styles
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/styles
parent700e395a3d2a0c9f6526fe7c69a92bd347fa1b88 (diff)
Support style mapping for highlights
Diffstat (limited to 'lib/styles')
-rw-r--r--lib/styles/document-matchers.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/styles/document-matchers.js b/lib/styles/document-matchers.js
index 005e2db..58c844a 100644
--- a/lib/styles/document-matchers.js
+++ b/lib/styles/document-matchers.js
@@ -7,6 +7,7 @@ exports.underline = new Matcher("underline");
exports.strikethrough = new Matcher("strikethrough");
exports.allCaps = new Matcher("allCaps");
exports.smallCaps = new Matcher("smallCaps");
+exports.highlight = highlight;
exports.commentReference = new Matcher("commentReference");
exports.lineBreak = new Matcher("break", {breakType: "line"});
exports.pageBreak = new Matcher("break", {breakType: "page"});
@@ -27,6 +28,10 @@ function table(options) {
return new Matcher("table", options);
}
+function highlight(options) {
+ return new HighlightMatcher(options);
+}
+
function Matcher(elementType, options) {
options = options || {};
this._elementType = elementType;
@@ -46,6 +51,16 @@ Matcher.prototype.matches = function(element) {
(this._breakType === undefined || this._breakType === element.breakType);
};
+function HighlightMatcher(options) {
+ options = options || {};
+ this._color = options.color;
+}
+
+HighlightMatcher.prototype.matches = function(element) {
+ return element.type === "highlight" &&
+ (this._color === undefined || element.color === this._color);
+};
+
function isList(element, levelIndex, isOrdered) {
return element.numbering &&
element.numbering.level == levelIndex &&