Skip to content

Instantly share code, notes, and snippets.

@sevvie
Last active December 20, 2015 08:49
Show Gist options
  • Save sevvie/6103301 to your computer and use it in GitHub Desktop.
Save sevvie/6103301 to your computer and use it in GitHub Desktop.
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