summaryrefslogtreecommitdiff
path: root/lib/style-reader.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2020-11-05 19:35:33 +0000
committerMichael Williamson <mike@zwobble.org>2020-11-05 19:35:33 +0000
commitf7cfac642bf63fac77c99d4cc30601ded8b2c107 (patch)
tree771fee9fc5c43e54f94a4f6bb7475edec50cda8e /lib/style-reader.js
parente832f604e34d344d996f8101023b6272085f934c (diff)
Add style mapping for all caps
Diffstat (limited to 'lib/style-reader.js')
-rw-r--r--lib/style-reader.js28
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/style-reader.js b/lib/style-reader.js
index f686b28..07521ad 100644
--- a/lib/style-reader.js
+++ b/lib/style-reader.js
@@ -39,7 +39,7 @@ function readDocumentMatcher(string) {
function documentMatcherRule() {
var sequence = lop.rules.sequence;
-
+
var identifierToConstant = function(identifier, constant) {
return lop.rules.then(
lop.rules.token("identifier", identifier),
@@ -48,15 +48,15 @@ function documentMatcherRule() {
}
);
};
-
+
var paragraphRule = identifierToConstant("p", documentMatchers.paragraph);
var runRule = identifierToConstant("r", documentMatchers.run);
-
+
var elementTypeRule = lop.rules.firstOf("p or r or table",
paragraphRule,
runRule
);
-
+
var styleIdRule = lop.rules.then(
classRule,
function(styleId) {
@@ -86,7 +86,7 @@ function documentMatcherRule() {
}
)
);
-
+
var styleNameRule = lop.rules.sequence(
lop.rules.tokenOfType("open-square-bracket"),
lop.rules.sequence.cut(),
@@ -95,7 +95,7 @@ function documentMatcherRule() {
lop.rules.tokenOfType("close-square-bracket")
).head();
-
+
var listTypeRule = lop.rules.firstOf("list type",
identifierToConstant("ordered-list", {isOrdered: true}),
identifierToConstant("unordered-list", {isOrdered: false})
@@ -130,7 +130,7 @@ function documentMatcherRule() {
return matcherOptions;
});
}
-
+
var paragraphOrRun = sequence(
sequence.capture(elementTypeRule),
sequence.capture(createMatcherSuffixesRule([
@@ -141,7 +141,7 @@ function documentMatcherRule() {
).map(function(createMatcher, matcherOptions) {
return createMatcher(matcherOptions);
});
-
+
var table = sequence(
lop.rules.token("identifier", "table"),
sequence.capture(createMatcherSuffixesRule([
@@ -156,9 +156,10 @@ function documentMatcherRule() {
var italic = identifierToConstant("i", documentMatchers.italic);
var underline = identifierToConstant("u", documentMatchers.underline);
var strikethrough = identifierToConstant("strike", documentMatchers.strikethrough);
+ var allCaps = identifierToConstant("all-caps", documentMatchers.allCaps);
var smallCaps = identifierToConstant("small-caps", documentMatchers.smallCaps);
var commentReference = identifierToConstant("comment-reference", documentMatchers.commentReference);
-
+
var breakMatcher = sequence(
lop.rules.token("identifier", "br"),
sequence.cut(),
@@ -187,6 +188,7 @@ function documentMatcherRule() {
italic,
underline,
strikethrough,
+ allCaps,
smallCaps,
commentReference,
breakMatcher
@@ -211,7 +213,7 @@ function htmlPathRule() {
}).valueOrElse(false);
}
);
-
+
var separatorRule = lop.rules.then(
lop.rules.optional(lop.rules.sequence(
lop.rules.tokenOfType("colon"),
@@ -229,7 +231,7 @@ function htmlPathRule() {
identifierRule,
lop.rules.tokenOfType("choice")
);
-
+
var styleElementRule = lop.rules.sequence(
capture(tagNamesRule),
capture(lop.rules.zeroOrMore(classRule)),
@@ -249,7 +251,7 @@ function htmlPathRule() {
}
return htmlPaths.element(tagName, attributes, options);
});
-
+
return lop.rules.firstOf("html path",
lop.rules.then(lop.rules.tokenOfType("bang"), function() {
return htmlPaths.ignore;
@@ -267,7 +269,7 @@ function htmlPathRule() {
)
);
}
-
+
var identifierRule = lop.rules.then(
lop.rules.tokenOfType("identifier"),
decodeEscapeSequences