diff --git a/README.md b/README.md index 0e300e3..8bb584f 100644 --- a/README.md +++ b/README.md @@ -694,7 +694,7 @@ echo 'Please reopen the shell to activate completion.' Find some contributor instructions in [DEVELOPER.md](docs/DEVELOPER.md). -#### AWK +### AWK The core of this tool is implemented in [AWK](https://en.wikipedia.org/wiki/AWK). Almost all major implementations of AWK will work. Tested and officially supported are [Gawk](https://www.gnu.org/software/gawk/), [BWK](https://github.com/onetrueawk/awk), [mawk](https://invisible-island.net/mawk/). This means that the default AWK implementation in your OS will work. diff --git a/mdbooker.awk b/mdbooker.awk index f7f82eb..fa87341 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -2,6 +2,7 @@ BEGIN { OUTDIR = "book" SUMMARY = OUTDIR "/SUMMARY.md" printf "" > SUMMARY + N = 0 H = 0 Title = "" Content = "" @@ -15,13 +16,14 @@ BEGIN { function handleTitle(h, md) { if (Title) { - md = Title ".md" + N++ + md = (N < 10 ? "0": "") N "_" Title ".md" print "generating: " md "..." - print Content > md + print Content > OUTDIR "/" md printf "%" ((H - 1) * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "-", Title, md >> SUMMARY } H = h - Title = trim(substr($0, h)) + Title = trim(substr($0, h+1)) Content = "" }