Skip to content

Commit

Permalink
Update TOC anchor algorithm to match "https://github.com/thlorenz/anc…
Browse files Browse the repository at this point in the history
…hor-markdown-header" (fixes "#--link-is-deprecated")
  • Loading branch information
tianon committed Nov 22, 2018
1 parent d9ac731 commit 3afc117
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions toc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ toc="$(
prefix = "\t" prefix
}
# https://github.com/thlorenz/anchor-markdown-header/blob/56f77a232ab1915106ad1746b99333bf83ee32a2/anchor-markdown-header.js#L20-L30
hash = tolower($0)
gsub(/['"'"'./`]/, "", hash)
gsub(/[^a-z0-9]+/, "-", hash)
gsub(/^-|-$/, "", hash)
gsub(/ /, "-", hash)
gsub(/[\/?!:\[\]`.,()*"'"'"';{}+=<>~\$|#@&–—]/, "", hash)
gsub(/[。?!,、;:“”【】()〔〕[]﹃﹄“ ”‘’﹁﹂—…-~《》〈〉「」]/, "", hash)
printf "%s[%s](#%s)\n", prefix, $0, hash
}
Expand Down

0 comments on commit 3afc117

Please sign in to comment.