markdown-code-blocks
A through stream that extracts code from Markdown content, optionally selecting only code blocks of a selected type.
Currently this only works with GFM-style fenced code blocks, I don't have a need for indentation based blocks (yet). This README file makes a nice example:
$ markdown-code-blocks -t javascript < ./README.md
Will output:
var fs = var assert = var concat = var markdownCodeBlocks = var readme = fs readme
Which you can pipe into node
to verify that this module is working:
$ markdown-code-blocks -t javascript < README.md | node
API
module.exports = (types: String|Array<String>) => Transform<String, String>
License
MIT