From 52277d3d72b67b54638bac9add80822e7aac29b3 Mon Sep 17 00:00:00 2001 From: xonix Date: Tue, 5 Mar 2024 02:44:43 +0200 Subject: [PATCH] Create site with documentation #164 --- mdbooker.awk | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index 36faf53..5f24e02 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -10,7 +10,7 @@ BEGIN { /^### / { handleTitle(3); next } /^#### / { handleTitle(4); next } /^#####/ { print "error: #####"; exit 1 } -{ Content = Content $0 "\n"; next } +{ Content = Content "\n" $0; next } function handleTitle(h, md,indent,dir,i,path) { if (Title) { @@ -19,14 +19,12 @@ function handleTitle(h, md,indent,dir,i,path) { print "generating: " (path = dir (dir ? "/" : "") (md = fname(Title) ".md")) "..." if (dir) system("mkdir -p '" BOOK dir "'") - print "# " Title > BOOK path - print Content >> 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 } - PathElements[H = h] = Title = trim(substr($0, h + 1)) - Content = "" + Content = "# " (Title = PathElements[H = h] = trim(substr($0, h + 1))) } END { handleTitle(-1) }