Created
October 24, 2012 13:10
-
-
Save lukego/3945964 to your computer and use it in GitHub Desktop.
Format program listings for Markdown
This file contains 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
sed -E -e 's/^/ /g' -e 's/^ --- ?//g' | pandoc -o listing.pdf - | |
That expression is a cheap literate programming system for Markdown. | |
Start commentary lines with '--- ' and they will be | |
markdown-formatted, the rest will be code. (Uses Lua comment syntax.) | |
Finally the right implementation of this idea: | |
http://fresh.homeunix.net/~luke/misc/emacs/pbook.pdf (program) | |
http://fresh.homeunix.net/~luke/misc/erlang/regtest.pdf (better example) | |
EXAMPLE INPUT: | |
--- ## Linux glue | |
--- | |
--- To take direct control of a PCI device on Linux requires a little | |
--- setup. This is facilitated by the sysfs (`/sys`) filesystem which | |
--- supports finding devices, checking their type, forcing kernel | |
--- drivers to unbind them, and other handy things. (sysfs is one great | |
--- Linux feature.) | |
function pcidev_is_82574 (device) | |
return io.open(path(device,"config"), "ro"):read(4) == "\x86\x80\xd3\x10" | |
end | |
EXAMPLE OUTPUT: | |
## Linux glue | |
To take direct control of a PCI device on Linux requires a little | |
setup. This is facilitated by the sysfs (`/sys`) filesystem which | |
supports finding devices, checking their type, forcing kernel | |
drivers to unbind them, and other handy things. (sysfs is one great | |
Linux feature.) | |
function pcidev_is_82574 (device) | |
return io.open(path(device,"config"), "ro"):read(4) == "\x86\x80\xd3\x10" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment