Skip to content

Commit

Permalink
Create site with documentation #164
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Mar 3, 2024
1 parent c91601c commit bd8c70c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions mdbooker.awk
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
BEGIN {
OUTDIR = "book"
SUMMARY = OUTDIR "/SUMMARY.md"
BOOK = "book"
SUMMARY = BOOK "/SUMMARY.md"
printf "" > SUMMARY
N = 0
H = 0
Title = ""
Content = ""
Expand All @@ -16,16 +15,16 @@ BEGIN {

function handleTitle(h, md,indent,fname) {
if (Title) {
N++
fname = Title
gsub(/ /, "_", fname)
md = (N < 10 ? "0" : "") N "_" fname ".md"
md = fname ".md"
print "generating: " md "..."
print Content > OUTDIR "/" md
print "# " Title > BOOK "/" md
print Content >> BOOK "/" md
indent = H - 2
if (indent < 0)
indent = 0
printf "%" (indent * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "-", Title, md >> SUMMARY
printf "%" (indent * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "- ", Title, md >> SUMMARY
}
H = h
Title = trim(substr($0, h + 1))
Expand Down

0 comments on commit bd8c70c

Please sign in to comment.