Make MUNGE generated table of contents (TOC) bookmark work when there are symbols in the headline
This commit is contained in:
@@ -75,6 +75,9 @@ func buildTOC(markdown []byte) ([]byte, error) {
|
||||
if numSharps > 0 {
|
||||
indent := strings.Repeat(" ", numSharps-1)
|
||||
bookmark := strings.Replace(strings.ToLower(heading), " ", "-", -1)
|
||||
// remove ' and ? in bookmarks
|
||||
bookmark = strings.Replace(bookmark, "?", "", -1)
|
||||
bookmark = strings.Replace(bookmark, "'", "", -1)
|
||||
tocLine := fmt.Sprintf("%s- [%s](#%s)\n", indent, heading, bookmark)
|
||||
buffer.WriteString(tocLine)
|
||||
}
|
||||
|
Reference in New Issue
Block a user