Skip to content

Commit

Permalink
feat: handle braces in header text
Browse files Browse the repository at this point in the history
  • Loading branch information
jar-b committed Jul 8, 2021
1 parent 9d21ba5 commit 01fe906
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions testdata/special.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ An example document with headers including special/uncommon characters to test g

## 'With single quotes'

## {With braces}
2 changes: 2 additions & 0 deletions testdata/special_toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ An example document with headers including special/uncommon characters to test g
* [`With backticks`](#with-backticks)
* ["With double quotes"](#with-double-quotes)
* ['With single quotes'](#with-single-quotes)
* [{With braces}](#with-braces)
<!---mdtoc end--->
## With/Slash

Expand All @@ -30,3 +31,4 @@ An example document with headers including special/uncommon characters to test g

## 'With single quotes'

## {With braces}
2 changes: 1 addition & 1 deletion toc.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func Parse(b []byte) (*Toc, error) {
// ex. `Header One Two` = `header-one-two`
func textToLink(s string) string {
// TODO: find a more comprehensive/formally documented list of these
rep := strings.NewReplacer(" ", "-", "/", "", ",", "", ".", "", "+", "", ":", "", ";", "", "`", "", `"`, "", `'`, "")
rep := strings.NewReplacer(" ", "-", "/", "", ",", "", ".", "", "+", "", ":", "", ";", "", "`", "", `"`, "", `'`, "", "{", "", "}", "")
return strings.ToLower(rep.Replace(s))
}

Expand Down

0 comments on commit 01fe906

Please sign in to comment.