In this blog post we demonstrate how to do “Literate programming” in Raku via (short) pipelines of Command Line Interface (CLI) scripts.
An alternative of this CLI-based process is to use Mathematica or Jupyter notebooks.
Presentation’s GitHub directory

Steps and components

Here is a narration of the diagram above:
- Write some text and code in a Markdown file
- Program visualizations with “JavaScript::D3”, [AAp2]
- Weave the Markdown file (i.e. “run it”)
- Using “Text::CodeProcessing”, [AAp3]
- If the woven file the does not have D3.js graphics go to 5
- Convert the woven Markdown file into HTML
- Using “Markdown::Grammar”, [AAp4]
- Examine results
- Go to 1
- Or finish “fiddling with it”
The conversions
The we use the document “Cryptocurrencies-explorations.md” (with Raku code over cryptocurrencies data.)
If no D3.js graphics are specified then we can use the shell command:
file-code-chunks-eval Cryptocurrencies-explorations.md
If D3.js graphics are specified then we can use the shell command:
file-code-chunks-eval Cryptocurrencies-explorations.md &&
from-markdown Cryptocurrencies-explorations_woven.md -t html -o out.html &&
open out.html
Remark: It is instructive to examine “Cryptocurrencies-explorations_woven.md” and compare it with “Cryptocurrencies-explorations.md”.
Remark The code chunks with graphics (using “JavaScript::D3”) have to have the chunk option setting results=asis
.
Remark The “JavaScript::D3” commands have to have the option settings format => 'html'
and div-id => ...
.
References
Articles
[AA1] Anton Antonov “Raku Text::CodeProcessing”, (2021), RakuForPrediction at WordPress.
[AA2] Anton Antonov “JavaScript::D3”, (2022), RakuForPrediction at WordPress.
[AA3] Anton Antonov “Further work on the Raku-D3.js translation”, (2022), RakuForPrediction at WordPress.
Packages
[AAp1] Anton Antonov, Data::Cryptocurrencies Raku package, (2023). GitHub/antononcube.
[AAp2] Anton Antonov, JavaScript::D3 Raku package, (2022). GitHub/antononcube.
[AAp3] Anton Antonov, Text::CodeProcessing Raku package, (2021). GitHub/antononcube.
[AAp4] Anton Antonov, Markdown::Grammar, (2022). GitHub/antononcube.