aboutsummaryrefslogtreecommitdiff
path: root/lib/options-reader.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-01-07 22:15:00 +0000
committerMichael Williamson <mike@zwobble.org>2014-01-07 22:15:00 +0000
commitb0bc37e59cb521890be25015a66a1ae5d4f5c6f7 (patch)
treed9b07722ae3551da7f87939a0bc90ae1220610a0 /lib/options-reader.js
parentceb3e9770eaf466710a93c0a66daa11f2721c9df (diff)
Move options reading to separate module
Diffstat (limited to 'lib/options-reader.js')
-rw-r--r--lib/options-reader.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/options-reader.js b/lib/options-reader.js
new file mode 100644
index 0000000..caf4fe5
--- /dev/null
+++ b/lib/options-reader.js
@@ -0,0 +1,42 @@
+exports.readOptions = readOptions;
+
+var extend = require("xtend");
+var _ = require("underscore");
+var style = require("./style-reader").readStyle;
+
+
+var standardOptions = {
+ styleMap: [
+ style("p.Heading1 => h1:fresh"),
+ style("p.Heading2 => h2:fresh"),
+ style("p.Heading3 => h3:fresh"),
+ style("p.Heading4 => h4:fresh"),
+ style("p:unordered-list(1) => ul > li:fresh"),
+ style("p:unordered-list(2) => ul|ol > li > ul > li:fresh"),
+ style("p:unordered-list(3) => ul|ol > li > ul|ol > li > ul > li:fresh"),
+ style("p:unordered-list(4) => ul|ol > li > ul|ol > li > ul|ol > li > ul > li:fresh"),
+ style("p:unordered-list(5) => ul|ol > li > ul|ol > li > ul|ol > li > ul|ol > li > ul > li:fresh"),
+ style("p:ordered-list(1) => ol > li:fresh"),
+ style("p:ordered-list(2) => ul|ol > li > ol > li:fresh"),
+ style("p:ordered-list(3) => ul|ol > li > ul|ol > li > ol > li:fresh"),
+ style("p:ordered-list(4) => ul|ol > li > ul|ol > li > ul|ol > li > ol > li:fresh"),
+ style("p:ordered-list(5) => ul|ol > li > ul|ol > li > ul|ol > li > ul|ol > li > ol > li:fresh")
+ ],
+ transformDocument: identity
+};
+
+function readOptions(options) {
+ options = options || {};
+ if (options.styleMap && _.isString(options.styleMap)) {
+ options.styleMap = options.styleMap.split("\n").map(function(line) {
+ return style(line.trim());
+ });
+ }
+
+ return extend(standardOptions, options);
+}
+
+
+function identity(value) {
+ return value;
+}