Last active
December 20, 2015 08:49
-
-
Save sevvie/6103301 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global <<< require \prelude-ls | |
fs = require \fs | |
yaml = require \js-yaml | |
marked = require \marked | |
hljs = require \highlight.js | |
jade = require \jade | |
marked.setOptions {highlight: (lang, code) -> | |
hljs.highlightAuto(lang, code).value | |
} | |
args = drop 2 process.argv | |
rawdoc = fs.readFileSync args.0 .to-string! .split "---\n" | |
rawdoc = drop 1 rawdoc | |
header = yaml.load rawdoc.0 | |
content = marked rawdoc.1 | |
jadetmpl = '''doctype 5 | |
html(lang="en") | |
head | |
title= header.title | |
link(rel="stylesheet", href="docco.css") | |
link(rel="stylesheet", href="style.css") | |
body | |
#page | |
header | |
h1= header.title | |
span By #{header.author} | |
article!= content | |
''' | |
jadec = jade.compile jadetmpl, {pretty: true} | |
output = jadec {header: header, content: content} | |
fs.writeFileSync args.0.replace(".txt", ".html"), output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment