aboutsummaryrefslogtreecommitdiff
path: root/lib/style-reader.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-05-03 21:42:37 +0100
committerMichael Williamson <mike@zwobble.org>2013-05-03 21:42:37 +0100
commit6d2453fd95214ca3269c3d9f7f1e2a00d3f3ceee (patch)
tree2cd9dc12f5080ebe21e1529582e38aa5c7c8800a /lib/style-reader.js
parentdc4025cae3964d0300b421b1b7ff486d9f4c5faf (diff)
Parse paragraph matcher
Diffstat (limited to 'lib/style-reader.js')
-rw-r--r--lib/style-reader.js23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/style-reader.js b/lib/style-reader.js
index d749743..be5d5d3 100644
--- a/lib/style-reader.js
+++ b/lib/style-reader.js
@@ -1,9 +1,25 @@
var lop = require("lop");
var RegexTokeniser = lop.RegexTokeniser;
+var documentMatchers = require("./document-matchers");
var htmlPaths = require("./html-paths");
exports.readHtmlPath = readHtmlPath;
+exports.readDocumentMatcher = readDocumentMatcher;
+
+
+function readDocumentMatcher(string) {
+ var paragraphRule = lop.rules.then(
+ lop.rules.token("identifier", "p"),
+ function() {
+ return documentMatchers.paragraph();
+ }
+ );
+
+ var matcherRule = paragraphRule;
+
+ return parseString(matcherRule, string);
+}
function readHtmlPath(string) {
@@ -55,10 +71,13 @@ function readHtmlPath(string) {
),
htmlPaths.elements
);
-
+ return parseString(styleRule, string);
+}
+
+function parseString(rule, string) {
var tokens = tokenise(string);
var parser = lop.Parser();
- var parseResult = parser.parseTokens(styleRule, tokens);
+ var parseResult = parser.parseTokens(rule, tokens);
if (!parseResult.isSuccess()) {
throw new Error("Failed to parse: " + describeFailure(parseResult));
}