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

Regression? Heading anchors duplicated. Manual overrides ignored in v. 60.0 #6548

Closed
kurankat opened this issue Nov 27, 2019 · 6 comments
Closed
Labels

Comments

@kurankat
Copy link

kurankat commented Nov 27, 2019

What version of Hugo are you using (hugo version)?

$ hugo version
Hugo Static Site Generator v0.60.0/extended windows/amd64 BuildDate: unknown

Does this issue reproduce with the latest release?

Yes

Issues

I maintain a Flora which has long lists of scientific names (Genus species) and long identification keys. I have been using manual override anchors in the format of {#anchor-text} to override the unpredictability of Hugo's automatic anchors

My headers are in the format of:

## 8 SPRENGELIA

### **1 Sprengelia incarnata** Sm., *Kongl. Vetensk. Acad. Nya Handl.* Ser. 2, 15: 263 (1794) {#1-s.-incarnata}

...

## 14 STYPHELIA

### **1 Styphelia adscendens** R.Br., *Prodr. Fl. Nov. Holland.* 537 (1810) {#1-s.-adscendens} 

Previously (v. 58) the resulting HTML was:

<h2 id="8-sprengelia">8 SPRENGELIA</h2>

<h3 id="1-s.-incarnata"><strong>1 Sprengelia incarnata</strong> Sm., <em>Kongl. Vetensk. Acad. Nya Handl.</em> Ser. 2, 15: 263 (1794)</h3>

...

<h2 id="14-styphelia">14 STYPHELIA</h2>

<h3 id="1-s.-adscendens"><strong>1 Styphelia adscendens</strong> R.Br., <em>Prodr. Fl. Nov. Holland.</em> 537 (1810)</h3>

The resulting HTML is now:

<h2 id="8-sprengelia">8 SPRENGELIA</h2>

<h3 id="1-s" class="-incarnata"><strong>1 Sprengelia incarnata</strong> Sm., <em>Kongl. Vetensk. Acad. Nya Handl.</em> Ser. 2, 15: 263 (1794)</h3>

...

<h2 id="14-styphelia">14 STYPHELIA</h2>

<h3 id="1-s" class="-adscendens"><strong>1 Styphelia adscendens</strong> R.Br., <em>Prodr. Fl. Nov. Holland.</em> 537 (1810)</h3>

The overrides are being ignored and the ID anchors (which need to be unique) are being repeated.

@kurankat
Copy link
Author

Additional information:

This is related to Goldmark. If I revert to BlackFriday, the issue disappears, and custom anchors are rendered correctly.

With custom anchors:

<h3 id="1-s.-incarnata"><strong>1 Sprengelia incarnata</strong> Sm., <em>Kongl. Vetensk. Acad. Nya Handl.</em> Ser. 2, 15: 263 (1794)</h3>

...

<h3 id="1-s.-adscendens"><strong>1 Styphelia adscendens</strong> R.Br., <em>Prodr. Fl. Nov. Holland.</em> 537 (1810)</h3>

Without custom anchors:

<h3 id="1-sprengelia-incarnata-sm-kongl-vetensk-acad-nya-handl-ser-2-15-263-1794"><strong>1 Sprengelia incarnata</strong> Sm., <em>Kongl. Vetensk. Acad. Nya Handl.</em> Ser. 2, 15: 263 (1794)</h3>

...

<h3 id="1-styphelia-adscendens-r-br-prodr-fl-nov-holland-537-1810"><strong>1 Styphelia adscendens</strong> R.Br., <em>Prodr. Fl. Nov. Holland.</em> 537 (1810)</h3>

@kaushalmodi
Copy link
Contributor

What you are seeing is because of the new attributes support in headings in Goldmark. See https://github.com/yuin/goldmark/blob/master/README.md#headings.

May be this should be a bug report on the Goldmark repo.. you do not have a space before the dot (.) in your id, and still it's parsed as a class attribute specifier. I don't know if that's the expected behavior, so you'll need to open an issue there.

A temporary workaround might be to disable the attribute rendering in Goldmark. See https://gohugo.io/getting-started/configuration-markup/#goldmark.

@kurankat
Copy link
Author

kurankat commented Nov 30, 2019

Thanks @kaushalmodi,

There is indeed a change in syntax for how Goldmark render custom attributes compared to BlackFriday's way of rendering custom anchor tags on headings. This is not a bug and just a change in syntax required. Unfortunately from Goldmark: "This syntax possibly changes in the future. Headings"

My workaround was to revert to BlackFriday until I can refactor the sites I keep.

The bug is the repeated ID categories. They should be unique, or they are useless for most purposes.

Should I be reporting this as a Goldmark bug?

@kaushalmodi
Copy link
Contributor

The bug is the repeated ID categories. They should be unique, or they are useless for most purposes.

Yes, Blackfriday auto-uniquified the id's even if the user manually provided identical id's.

It would be a very useful feature request on Goldmark repo.

@kurankat
Copy link
Author

Thanks @kaushalmodi!

@github-actions
Copy link

This issue 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 Feb 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants