From e4b8f787679c570e4317136fc66501f4f44d8811 Mon Sep 17 00:00:00 2001 From: xonix Date: Tue, 5 Mar 2024 02:38:02 +0200 Subject: [PATCH] Create site with documentation #164 --- mdbooker.awk | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index b4eff63..36faf53 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -1,10 +1,7 @@ BEGIN { - BOOK = "book" - SUMMARY = BOOK "/SUMMARY.md" - printf "" > SUMMARY + printf "" > (SUMMARY = (BOOK = "book/") "SUMMARY.md") H = 0 - Title = "" - Content = "" + Title = Content = "" delete PathElements } @@ -17,18 +14,14 @@ BEGIN { function handleTitle(h, md,indent,dir,i,path) { if (Title) { - md = fname(Title) ".md" - dir = "" - for (i=2; i BOOK "/" path - print Content >> BOOK "/" path - indent = H - 2 - if (indent < 0) + print "generating: " (path = dir (dir ? "/" : "") (md = fname(Title) ".md")) "..." + if (dir) + system("mkdir -p '" BOOK dir "'") + print "# " Title > BOOK path + print Content >> BOOK path + if ((indent = H - 2) < 0) indent = 0 printf "%" (indent * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "- ", Title, path >> SUMMARY }