Adding a CLI for rendering

This commit is contained in:
Shan Carter
2017-02-06 15:11:38 -08:00
parent 5dac7eed8b
commit 0c49900eae
4 changed files with 52 additions and 53 deletions
Executable
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env node
var fs = require("fs"),
jsdom = require("jsdom").jsdom,
serializeDocument = require("jsdom").serializeDocument,
distill = require("../dist/template.js"),
program = require('commander');
program
.version('0.0.1')
.option('-i, --input <path>', 'path to input file.')
.parse(process.argv);
let htmlString = fs.readFileSync(program.input, "utf8");
var dom = jsdom(htmlString, {features: {ProcessExternalResources: false, FetchExternalResources: false}});
distill.render(dom, {});
let transformedHtml = serializeDocument(dom);
process.stdout.write(transformedHtml);
-11
View File
@@ -63,15 +63,4 @@ function render(dom, data) {
}
export {render as render};
export {html as html};
export {styles as styles};
export {frontMatter as frontMatter};
export {bibliography as bibliography};
export {meta as meta};
export {header as header};
export {appendix as appendix};
export {footer as footer};
export {citation as citation};
export {markdown as markdown};
export {code as code};
export {generateCrossref as generateCrossref};
+2 -1
View File
@@ -22,7 +22,7 @@
"bibtex-parse-js": "^0.0.23",
"chai": "^3.5.0",
"js-yaml": "^3.7.0",
"jsdom": "^9.9.1",
"jsdom": "^9.10.0",
"marked": "^0.3.6",
"mocha": "^3.2.0",
"prismjs": "^1.6.0",
@@ -37,6 +37,7 @@
"rollup-watch": "^2.5.0"
},
"dependencies": {
"commander": "^2.9.0",
"d3-time-format": "^2.0.3",
"mustache": "^2.3.0"
}
+32 -41
View File
@@ -2,7 +2,7 @@
# yarn lockfile v1
abab@^1.0.0:
abab@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.3.tgz#b81de5f7274ec4e756d797cd834f303642724e5d"
@@ -10,11 +10,11 @@ abbrev@1:
version "1.0.9"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135"
acorn-globals@^1.0.4:
version "1.0.9"
resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-1.0.9.tgz#55bb5e98691507b74579d0513413217c380c54cf"
acorn-globals@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-3.1.0.tgz#fd8270f71fbb4996b004fa880ee5d46573a731bf"
dependencies:
acorn "^2.1.0"
acorn "^4.0.4"
acorn-jsx@^3.0.1:
version "3.0.1"
@@ -28,15 +28,11 @@ acorn-object-spread@^1.0.0:
dependencies:
acorn "^3.1.0"
acorn@^2.1.0, acorn@^2.4.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-2.7.0.tgz#ab6e7d9d886aaca8b085bc3312b79a198433f0e7"
acorn@^3.0.4, acorn@^3.1.0, acorn@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a"
acorn@^4.0.1:
acorn@^4.0.1, acorn@^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.4.tgz#17a8d6a7a6c4ef538b814ec9abac2779293bf30a"
@@ -321,11 +317,11 @@ cryptiles@2.x.x:
dependencies:
boom "2.x.x"
cssom@0.3.x, "cssom@>= 0.3.0 < 0.4.0":
version "0.3.1"
resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.1.tgz#c9e37ef2490e64f6d1baa10fda852257082c25d3"
cssom@0.3.x, "cssom@>= 0.3.2 < 0.4.0":
version "0.3.2"
resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.2.tgz#b8036170c79f07a90ff2f16e22284027a243848b"
"cssstyle@>= 0.2.36 < 0.3.0":
"cssstyle@>= 0.2.37 < 0.3.0":
version "0.2.37"
resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-0.2.37.tgz#541097234cb2513c83ceed3acddc27ff27987d54"
dependencies:
@@ -648,10 +644,6 @@ iconv-lite@0.4.13:
version "0.4.13"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.13.tgz#1f88aba4ab0b1508e8312acc39345f36e992e2f2"
iconv-lite@^0.4.13:
version "0.4.15"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb"
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
@@ -769,30 +761,29 @@ jsbn@~0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.0.tgz#650987da0dd74f4ebf5a11377a2aa2d273e97dfd"
jsdom@^9.9.1:
version "9.9.1"
resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-9.9.1.tgz#84f3972ad394ab963233af8725211bce4d01bfd5"
jsdom@^9.10.0:
version "9.10.0"
resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-9.10.0.tgz#72d04d9fd5f1164d016dc350ef889af6d0d1a25a"
dependencies:
abab "^1.0.0"
acorn "^2.4.0"
acorn-globals "^1.0.4"
abab "^1.0.3"
acorn "^4.0.4"
acorn-globals "^3.1.0"
array-equal "^1.0.0"
content-type-parser "^1.0.1"
cssom ">= 0.3.0 < 0.4.0"
cssstyle ">= 0.2.36 < 0.3.0"
cssom ">= 0.3.2 < 0.4.0"
cssstyle ">= 0.2.37 < 0.3.0"
escodegen "^1.6.1"
html-encoding-sniffer "^1.0.1"
iconv-lite "^0.4.13"
nwmatcher ">= 1.3.9 < 2.0.0"
parse5 "^1.5.1"
request "^2.55.0"
sax "^1.1.4"
symbol-tree ">= 3.1.0 < 4.0.0"
tough-cookie "^2.3.1"
request "^2.79.0"
sax "^1.2.1"
symbol-tree "^3.2.1"
tough-cookie "^2.3.2"
webidl-conversions "^3.0.1"
whatwg-encoding "^1.0.1"
whatwg-url "^4.1.0"
xml-name-validator ">= 2.0.1 < 3.0.0"
whatwg-url "^4.3.0"
xml-name-validator "^2.0.1"
json-schema@0.2.3:
version "0.2.3"
@@ -1200,7 +1191,7 @@ repeat-string@^1.5.2:
version "1.6.1"
resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637"
request@^2.55.0, request@^2.79.0:
request@^2.79.0:
version "2.79.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.79.0.tgz#4dfe5bf6be8b8cdc37fcf93e04b65577722710de"
dependencies:
@@ -1314,7 +1305,7 @@ rollup@^0.36.4:
dependencies:
source-map-support "^0.4.0"
sax@>=0.6.0, sax@^1.1.4:
sax@>=0.6.0, sax@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.1.tgz#7b8e656190b228e81a66aea748480d828cd2d37a"
@@ -1419,7 +1410,7 @@ supports-color@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
"symbol-tree@>= 3.1.0 < 4.0.0":
symbol-tree@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.1.tgz#8549dd1d01fa9f893c18cc9ab0b106b4d9b168cb"
@@ -1448,7 +1439,7 @@ tiny-emitter@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/tiny-emitter/-/tiny-emitter-1.1.0.tgz#ab405a21ffed814a76c19739648093d70654fecb"
tough-cookie@^2.3.1, tough-cookie@~2.3.0:
tough-cookie@^2.3.2, tough-cookie@~2.3.0:
version "2.3.2"
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a"
dependencies:
@@ -1529,9 +1520,9 @@ whatwg-encoding@^1.0.1:
dependencies:
iconv-lite "0.4.13"
whatwg-url@^4.1.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-4.2.0.tgz#abf1a3f5ff4bc2005b3f0c2119382631789d8e44"
whatwg-url@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-4.3.0.tgz#92aaee21f4f2a642074357d70ef8500a7cbb171a"
dependencies:
tr46 "~0.0.3"
webidl-conversions "^3.0.0"
@@ -1565,7 +1556,7 @@ ws@^1.1.1:
options ">=0.0.5"
ultron "1.0.x"
"xml-name-validator@>= 2.0.1 < 3.0.0":
xml-name-validator@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-2.0.1.tgz#4d8b8f1eccd3419aa362061becef515e1e559635"