Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knit creates invalid TOC links when text contains quotation mark " #45

Open
aSemy opened this issue Oct 20, 2022 · 1 comment · May be fixed by #46
Open

Knit creates invalid TOC links when text contains quotation mark " #45

aSemy opened this issue Oct 20, 2022 · 1 comment · May be fixed by #46

Comments

@aSemy
Copy link

aSemy commented Oct 20, 2022

Given some markdown

#### Using `JsonUnquotedLiteral` to encode `"null"` is forbidden

To avoid creating an inconsistent state, encoding a String equal to `"null"` is forbidden. 
Use [JsonNull] or [JsonPrimitive] instead.

Knit generates an invalid link

    * [Using `JsonUnquotedLiteral` to encode `"null"` is forbidden](#using-jsonunquotedliteral-to-encode-"null"-is-forbidden)

image

If I change the link to remove the quotation marks, then it works as expected.

    * [Using `JsonUnquotedLiteral` to encode `"null"` is forbidden](#using-jsonunquotedliteral-to-encode-null-is-forbidden)
@aSemy aSemy changed the title Knit creates invalid links when text contains quotation mark " Knit creates invalid TOC links when text contains quotation mark " Oct 20, 2022
@aSemy aSemy linked a pull request Oct 20, 2022 that will close this issue
@aSemy
Copy link
Author

aSemy commented Oct 20, 2022

I found this comment, https://gist.github.com/asabaylus/3071099?permalink_comment_id=1593627#gistcomment-1593627

The code that creates the anchors is here: https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/toc_filter.rb

  1. It downcases the string
  2. remove anything that is not a letter, number, space or hyphen (see the source for how Unicode is handled)
  3. changes any space to a hyphen.
  4. If that is not unique, add "-1", "-2", "-3",... to make it unique

It's from 2015, so this might be outdated. Perhaps this logic can be used to make the link handling more robust.

See also: https://github.com/imthenachoman/nGitHubTOC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant