Skip to content

Commit

Permalink
feat: handle backticks, double, single quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
jar-b committed Jul 7, 2021
1 parent 00e9989 commit 9d21ba5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions testdata/special.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ An example document with headers including special/uncommon characters to test g

## With:Colon;SemiColon

## `With backticks`

## "With double quotes"

## 'With single quotes'

9 changes: 9 additions & 0 deletions testdata/special_toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ An example document with headers including special/uncommon characters to test g
* [With.Period](#withperiod)
* [With+Plus](#withplus)
* [With:Colon;SemiColon](#withcolonsemicolon)
* [`With backticks`](#with-backticks)
* ["With double quotes"](#with-double-quotes)
* ['With single quotes'](#with-single-quotes)
<!---mdtoc end--->
## With/Slash

Expand All @@ -21,3 +24,9 @@ An example document with headers including special/uncommon characters to test g

## With:Colon;SemiColon

## `With backticks`

## "With double quotes"

## 'With single quotes'

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 9d21ba5

Please sign in to comment.