Skip to content

@lukego /pbook in sed
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Format program listings for Markdown
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
Something went wrong with that request. Please try again.