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

Remove trailing hyphen from auto heading ID #7459

Merged
merged 1 commit into from
Jul 5, 2020
Merged

Remove trailing hyphen from auto heading ID #7459

merged 1 commit into from
Jul 5, 2020

Conversation

jmooring
Copy link
Member

@jmooring jmooring commented Jul 4, 2020

Applicable when autoHeadingIDType is either github or github-ascii.

When autoHeadingIDType is blackfriday, the existing code removes
trailing whitespace while iterating through the characters, using
a boolean "futureDash" mechanism.

Fixes #6798

Applicable when autoHeadingIDType is either `github` or `github-ascii`.

When autoHeadingIDType is `blackfriday`, the existing code removes
trailing whitespace while iterating through the characters, using
a boolean "futureDash" mechanism.

Fixes #6798
@bep
Copy link
Member

bep commented Jul 4, 2020

Thanks for this,

These "auto ID" schemes are very "compatibility aware" so to speak, so I'm not keen to change stuff to make it prettier -- but I would be happyt to merge this if the "blackfriday ID" behaved differently before we got this Goldmark upgrade, did it?

@jmooring
Copy link
Member Author

jmooring commented Jul 4, 2020

Without this PR, and with config.toml as follows:

[markup.goldmark.parser]
autoHeadingIDType = "blackfriday"

trailing spaces are removed from the auto heading ID.

I did not test < 0.60.

@jmooring
Copy link
Member Author

jmooring commented Jul 4, 2020

Just tested with Hugo Static Site Generator v0.59.1-D5DAB232/extended linux/amd64 BuildDate: 2019-10-31T15:28:09Z.

Example markdown: # Foo #

Parser Version HTML  
Blackfriday 0.59.1 <h1 id="foo">Foo</h1>
Blackfriday 0.73 <h1 id="foo">Foo</h1>
Goldmark with autoHeadingIDType = blackfriday 0.73 <h1 id="foo">Foo</h1>
Goldmark with autoHeadingIDType = github 0.73 <h1 id="foo-">Foo</h1> <--
Goldmark with autoHeadingIDType = github-ascii 0.73 <h1 id="foo-">Foo</h1> <--
Blackfriday 0.73 + this PR <h1 id="foo">Foo</h1>
Goldmark with autoHeadingIDType = blackfriday 0.73 + this PR <h1 id="foo">Foo</h1>
Goldmark with autoHeadingIDType = github 0.73 + this PR <h1 id="foo">Foo</h1>
Goldmark with autoHeadingIDType = github-ascii 0.73 + this PR <h1 id="foo">Foo</h1>

@bep
Copy link
Member

bep commented Jul 5, 2020

Note that the relevant thing to look at in the above is how GitHub behaves -- but I added this test case to https://github.com/bep/portable-hugo-links/blob/master/blog/p2.md#trailing-space -- which shows that Hugo/GitHub differs.

@bep bep merged commit 58c0f5e into gohugoio:master Jul 5, 2020
@jmooring jmooring deleted the issue-6798 branch July 5, 2020 12:25
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unexpected trailing dash in auto heading ID for "# heading #"
2 participants