summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-05-03 21:52:52 +0100
committerMichael Williamson <mike@zwobble.org>2013-05-03 21:52:52 +0100
commit4746d8f52c7287f9f71f393f6a5220130ed3d984 (patch)
tree1893734a164fd7beb705875c7d5299e540c2eee4
parent2558a4cc0df494f7b9380e9b34b85c5dd1c83010 (diff)
Add parsing for run matchers
-rw-r--r--lib/style-reader.js14
-rw-r--r--tests/style-reader.tests.js7
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/style-reader.js b/lib/style-reader.js
index 757dc30..be5ab20 100644
--- a/lib/style-reader.js
+++ b/lib/style-reader.js
@@ -18,8 +18,20 @@ function readDocumentMatcher(string) {
}
);
+ var runRule = lop.rules.then(
+ lop.rules.token("identifier", "r"),
+ function() {
+ return documentMatchers.run;
+ }
+ );
+
+ var elementTypeRule = lop.rules.firstOf("p or r",
+ paragraphRule,
+ runRule
+ );
+
var matcherRule = sequence(
- sequence.capture(paragraphRule),
+ sequence.capture(elementTypeRule),
sequence.capture(lop.rules.optional(classRule))
).map(function(createMatcher, styleName) {
return createMatcher(styleName.valueOrElse());
diff --git a/tests/style-reader.tests.js b/tests/style-reader.tests.js
index d96ba87..c9bfe5b 100644
--- a/tests/style-reader.tests.js
+++ b/tests/style-reader.tests.js
@@ -51,4 +51,11 @@ describe("styleReader.readDocumentMatcher", function() {
documentMatchers.paragraph("Heading1")
);
});
+
+ test("reads plain run", function() {
+ assert.deepEqual(
+ readDocumentMatcher("r"),
+ documentMatchers.run()
+ );
+ });
});