0.2.0 • Published 7 years agoCLI
@jamen/markdown-to-code
Licence
—
Version
0.2.0
Deps
0
Size
7 kB
Vulns
0
Weekly
0
@jamen/markdown-to-code
A literate programming tool using markdown and codeblocks. It turns codeblocks into source code and the rest of the content into comments, allowing you to execute or analyze only the code.
Install
npm i @jamen/markdown-to-code
Or quickly use command-line utility:
npx @jamen/markdown-to-code foo.md foo.js
Usage
markdownCode(options?)
Compiles an input stream with the given options, returns a readable stream.
let compileMarkdown = markdownCode({
language: 'js',
mode: {
opener: '/**',
normal: ' * ',
closer: ' **/'
}
})
createReadStream('input.md')
.pipe(compileMarkdown)
.pipe(createWriteStream('output.js'))
markdown-to-code <input> <output>
Command-line tool that compiles the input file to the output file. Uses stdio without files.
Use --mode or -m to set the commenting mode (see lib/modes.json).
To opt-in or opt-out of codeblocks turning into code, you use HTML comments above them containing the word "export". By default this is an opt-in behavior, but you can use the --all or -a flag to make it opt-out (everything is exported)