From 6ab4332965443cca574ecd8ce8559cc4533b9e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Sun, 8 Aug 2021 09:56:15 +0200 Subject: [PATCH] feat: add literate programming script --- .bin/lit.awk | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .bin/lit.awk diff --git a/.bin/lit.awk b/.bin/lit.awk new file mode 100644 index 0000000..7346b37 --- /dev/null +++ b/.bin/lit.awk @@ -0,0 +1,17 @@ +BEGIN { + if (!comment) comment = "--"; + if (!begin) begin = "\\begin{code}"; + if (!end) end = "\\end{code}"; +} +{ + if ($0 == begin) { + code = 1; + print comment, $0; + } else if ($0 == end) { + code = 0; + print comment, $0; + } else { + if (code) print $0; + else print comment, $0; + } +}