computable-pandoc/README.md

51 lines
1.9 KiB
Markdown
Raw Normal View History

2023-02-17 12:46:39 -06:00
# Pandoc Literate Programming
2023-02-16 19:19:47 -06:00
[Pandoc] is world famous as a "swiss-army" document converted. However, this is
because Pandoc is also a document parser. Thanks to this capability, this repo
is a [Pandoc filter] for [literate programming][]: evaluate the code written in
your documents with Pandoc and [Lua].
2023-02-17 13:38:38 -06:00
> NOTE: Pandoc has [Literate Haskell support], but it doesn't support all input
> and output formats. This filter tries to support to all of them.
2023-02-16 19:19:47 -06:00
## Usage
In your terminal, just execute:
sh tests/test.sh FORMAT
Pick one or more [FORMAT namespaces], e.g.:
sh tests/test.sh markdown html
2023-02-16 19:25:48 -06:00
You can also use this filter for your documents:[^1]
2023-02-16 19:19:47 -06:00
pandoc --lua-filter literate.lua -t FORMAT YOUR_DOC
2023-02-16 19:25:48 -06:00
Besides your document, you must add the class `eval` in the [fenced code
blocks] that you want to evaluate. If you also want to replace the code block
content with the evaluation result, you also must add the class `replace`.
Check [this test] if you don't known what I am talking about.
2023-02-16 19:19:47 -06:00
Happy hacking :)
2023-02-17 13:38:38 -06:00
## TODO
In order to support any markup language, the filter:
- Can't rely in the built-in pandoc code blocks.
- Requires syntaxis for custom literate programming blocks.
2023-02-16 19:19:47 -06:00
[^1]: Right now this is only for testing, so only a subset of Lisp function are
supported (`+`, `list`, `first`)... The objective is to support any
programming language and more!
[Pandoc]: https://pandoc.org/
[Pandoc filter]: https://pandoc.org/lua-filters.html
[literate programming]: https://en.wikipedia.org/wiki/Literate_programming
[Lua]: https://www.lua.org/
2023-02-17 13:38:38 -06:00
[Literate Haskell support]: https://pandoc.org/MANUAL.html#literate-haskell-support
2023-02-16 19:19:47 -06:00
[FORMAT namespaces]: https://pandoc.org/MANUAL.html#option--to
[fenced code blocks]: https://pandoc.org/MANUAL.html#fenced-code-blocks
2023-02-16 19:25:48 -06:00
[this test]: https://git.cuates.net/perro/literate-pandoc/src/branch/no-masters/tests/src/t2.md?display=source