-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
anchorlinenos
and lineanchors
attributes do not work when using with code fences
#9385
Comments
When using code fences, the available options are limited by the yuin/goldmark-highlighting module (upstream). The More info: |
I really wanted to move away from using the I'll close this issue given that this is recognized as an expected behavior. |
Or set the default in site configuration: [markup.highlight]
anchorLineNos = true |
Yeah, I realized that that worked. But my sites have hundreds of code blocks and I don't want to enable the anchors for every line. That makes me think.. why does enabling that variable in site config work even for code fences? |
I think that if Hugo makes the |
@bep Can you please take a look at this? Is it possible to make this work by any change from the Hugo side?
Right now, the line anchors don't get enabled if we use code fences; they work only with the
|
There are now 1 handling of this config so I assume that your case will now just work, but I would soonish merge my work into master branch, and would appreciate if "someone else" could verify this then. |
Now that Hugo issue gohugoio/hugo#9385 is fixed in Hugo v0.93.0 (https://github.com/gohugoio/hugo/releases/tag/v0.93.0), this workaround (of using the `highlight` shortcode only when coderefs were used) is no longer needed. This is "minor" breaking because the coderefs feature was introduced very recently and so I doubt if anyone is still using this :D If users want to use coderefs, they need to upgrade Hugo to v0.93.0 Documentation for coderef support: https://ox-hugo.scripter.co/doc/source-blocks/#code-references
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. |
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
Yes
Hugo Discourse discussion
https://discourse.gohugo.io/t/bug-anchorlinenos-true-attribute-doesnt-work-when-using-code-fences/36564
Reproducible example
Steps to reproduce the problem
git clone https://gitlab.com/hugo-mwe/hugo-mwe cd hugo-mwe git checkout anchorlinenos ./srv.sh
Analysis
It looks like the
anchorlinenos
andlineanchors
attributes get passed on as-is to the rendered HTML without being treated as special attributes for creating line number hyperlinks.I see this when I look at the source of the above test HTML page:
Possibly related code:
hugo/markup/goldmark/render_hooks.go
Lines 149 to 154 in fcbbbef
The link anchoring feature was added in fb0f2cc but the new attributes probably still need to be added in
render_hooks.go
. /cc @fjorgemotaThe text was updated successfully, but these errors were encountered: