diff --git a/mdbooker.awk b/mdbooker.awk index 507c430..3e83cc9 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -1,4 +1,5 @@ BEGIN { + Base = ENVIRON["BASE"] printf "" > (SUMMARY = (BOOK = "book/") "SUMMARY.md") H = 0 Title = Content = "" @@ -35,8 +36,12 @@ function pass2( l,f,t) { handleTitle(RLENGTH, 2) else { if (match(l = $0, /]\(#[^)]+\)/)) { - print " fix link: #" (f=substr(l, RSTART + 3, RLENGTH - 4)) " -> " (t = Link2Path[f]) + print " fix link: #" (f = substr(l, RSTART + 3, RLENGTH - 4)) " -> " (t = Link2Path[f]) l = substr(l, 1, RSTART - 1) "](" t ")" substr(l, RSTART + RLENGTH) + } else if (match(l,/]\([^)]+\)/) && (f = substr(l, RSTART + 2, RLENGTH - 3)) !~ /https?:/) { + print " fix link: " f " -> " (t = Base f) + l = substr(l, 1, RSTART - 1) "](" t ")" substr(l, RSTART + RLENGTH) + print ">>" l } Content = Content "\n" l }