From: Paul Hänsch Date: Sun, 2 Jul 2023 18:29:00 +0000 (+0200) Subject: block level prefix to avoid repeating headline IDs X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=33570b0d2e2697cc7196a7a0ddc34cc2b4edd71b;p=cgilite block level prefix to avoid repeating headline IDs --- diff --git a/markdown.awk b/markdown.awk index 71c91fd..16acc25 100755 --- a/markdown.awk +++ b/markdown.awk @@ -312,7 +312,8 @@ function headline( hlvl, htxt, LOCAL, sec, n, HL) { for ( n = hlvl; n <= 6; n++ ) { sec = sec (HL[n]?"":""); } HL[hlvl]++; for ( n = hlvl + 1; n <= 6; n++) { HL[n] = 0;} - hid = HL[1]; for ( n = 2; n <= hlvl; n++) { hid = hid "." HL[n] ; } + hid = ""; for ( n = 2; n <= blvl; n++) { hid = hid BL[n] "/"; } + hid = hid HL[1]; for ( n = 2; n <= hlvl; n++) { hid = hid "." HL[n] ; } # hid = hid ":" URL(htxt, 1); hstack = gensub( /^(.* )?([0-9]+( [0-9]+){5})$/, "\\1" ,"1", hstack) \ @@ -325,12 +326,13 @@ function headline( hlvl, htxt, LOCAL, sec, n, HL) { } # Nested Block, resets heading counters -function _nblock( block, LOCAL, hlsav, sec ) { +function _nblock( block, LOCAL, hlsav, sec, n ) { hlsav = hstack; hstack = hstack " 0 0 0 0 0 0"; # Block Level - blvl++; + blvl++; BL[blvl]++; + for ( n = blvl + 1; n in BL; n++) { delete BL[n]; } block = _block( block ); split( gensub( /^(.* )?([0-9]+( [0-9]+){5})$/, "\\2" ,"1", hstack), HL);