From 4746d8f52c7287f9f71f393f6a5220130ed3d984 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 3 May 2013 21:52:52 +0100 Subject: Add parsing for run matchers --- lib/style-reader.js | 14 +++++++++++++- tests/style-reader.tests.js | 7 +++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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() + ); + }); }); -- cgit v1.2.3