Handy if you want to have your code blocks highlighted when posting your literate script as a Gist or as a README.md file for your repo ... or to convert a markdown file with fenced code blocks to literate source.
Note that this utility only converts code blocks in markdown files from one format to another. See this gist for a demonstration of how to run or extract code blocks from any literate source file.
npm install fence-filter should yield:
$ which fence /usr/local/bin/fence
Suppose we have a file,
demo.python.md, containing ...
# Demo print "hello world!"
And now we want to fence the code blocks in this file so that they'll be rendered nicely when people look at our demo file on Github. That is, we want ...
# Demo ```python print "hello world!" ```
... so that the codeblock is rendered all pretty:
print "hello world!"
fence demo.python.md > demo.md fence demo.coffee.md > demo.md fence demo.litcoffee > demo.md cat demo.python.md | fence --lang python > demo.md cat demo.coffee.md | fence --lang coffee > demo.md
You can also "undo" fencing:
fence --undo demo.md > demo.litcoffee cat demo.md | fence --undo > demo.litcoffee
fence demo.litcoffee | fence --undo > demo.litcoffee
HT to @jashkenas, this is but a tweak of journo's Cakefile.