Tools for literate programming using pandoc's markdown format.
- Write a program and its design/description in one markdown document.
- Generate a printable/publishable document from the markdown document.
- Generate one or more programs from the markdown document which can be used to run the program.
This program is written as a "literate program" in markdown. See litpd.md.
litpd is a command-line application to be used in your own build or document generation process.
You can download the source code by cloning this repo or downloading the source zip file.
Pre-requisites for build:
- Lua interpreter in path.
- gnu make in path.
- Pandoc in path.
In the directory containing the litpd source, run the following command:
$ make clean all
This will create a dist directory and generate all the build artifacts in this directory.
Run the program by executing the litpd.lua
with the name of the input markdown
file and any options to be passed to pandoc.
lua <litpd_dir>/dist/litpd.lua program.md --to=html
If the markdown program is a simple hello world like this one...
hello.md
notice the options to the code block inside curly braces.
# Hello World! This is a simple hello world program in lua. ```lua { code_file = "hello.lua" } print('hello') ```
If we run the following litpd command...
lua <litpd_dir>/dist/litpd.lua hello.md --to=html
Two files will be generated in the current folder:
- hello.html - the markdown document converted to html by pandoc.
- hello.lua - the program with the source code in the code block.