#!/usr/bin/env mf # # mf mellifera-sources-to-markdown.mf ~/sources/mellifera | pandoc --standalone --pdf-engine=lualatex --from=markdown --to=pdf --output=out.pdf let repo = null; let argi = 1; while argi < argv.count() { if repo != null { error $"repo already specified as {repo}"; } repo = argv[argi]; argi = argi + 1; } if repo == null { error "repo not specified"; } # At the time of writing LuaTeX appears to have a bug where emoji containing # the Unicode variation selector 16 causes the LuaTeX to blow up during text # shaping with HarfBuzz. The Mellifera README.md contains a Red Heart, which # contains the VS16 as a modifier to the Heavy Black Heart emoji. A recent bug # report on the lualatex-dev mailing list[1], presents the same issue with the # Warning emoji, which also contains the VS16 bytes. # # [1]: https://tug.org/pipermail/lualatex-dev/2026-June/001728.html let normalize = function(s) { return s.replace( "\xE2\x9D\xA4\xEF\xB8\x8F", # Heavy Black Heart + VS16 "\xE2\x9D\xA4", # Heavy Black Heart ); }; let files = [ "README.md", "overview.mf", "GRAMMAR", "LICENSE", "Makefile", "go.mod", "mellifera.go", "cmd/mf/mf.go", "cmd/wasm/wasm.go", "bin/mf-test", ] + sh::runx($"cd {sh::quote(repo)} && find examples -name '*.mf'").stdout.trim().split("\n").sorted(); let sha = sh::runx($"cd {sh::quote(repo)} && git rev-parse HEAD").stdout.trim(); let ymd = sh::runx($"cd {sh::quote(repo)} && git log -1 --format='%ad' --date=format:'%Y-%m-%d'").stdout.trim(); println($``` --- title: 'The Mellifera Programming Language' subtitle: | | Commit {sha} | Commit Date {ymd} geometry: margin=0.85in mainfont: SourceCodePro monofont: SourceCodePro monofontfallback: - 'Apple Color Emoji:mode=harf' documentclass: scrbook fontsize: 9pt header-includes: - '\usepackage{{fvextra}}' - '\DefineVerbatimEnvironment{{Highlighting}}{{Verbatim}}{{breaklines,commandchars=\\\{{\}}}}' --- \tableofcontents \newpage ```.trim()); for file in files { println($``` # {file} ~~~{{.numberLines}} {normalize(fs::read($"{repo}/{file}"))} ~~~ ```.trim()); }