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

[feature request] Support for linkable line numbers as supported by Chroma #25

Closed
kaushalmodi opened this issue Jan 14, 2022 · 4 comments

Comments

@kaushalmodi
Copy link

Hello,

Can you please enable the support of LinkableLineNumbers() as supported by Chroma?

https://github.com/alecthomas/chroma#the-html-formatter

Hugo supported enabling the generation of linkable line numbers by passing the anchorlinenos=true attribute to the Hugo highlight shortcode. That shortcode internally uses the same Chroma library to do the code syntax highlighting.

Right now, the highlight shortcode inherits this anchorlinenos=true feature from Chroma. But if I try to use code fences with that attribute, I do not get anchorized line numbers because this library doesn't support that.

Thanks!


References

@jmooring
Copy link

If implemented, please remember that there may be two or more fenced code blocks in the same document. That means that the id of the element wrapping the line number must be unique to the document, not just the code block in which it occurs. Perhaps two attributes: a boolean to enable/disable, and a string to prepend to the id.

@kaushalmodi
Copy link
Author

kaushalmodi commented Jan 14, 2022

@jmooring

Perhaps two attributes: a boolean to enable/disable, and a string to prepend to the id.

Just to clarify, those would be equivalent to the anchorlinenos (boolean) and lineanchor (string) in Hugo, right?

I want to make sure that this extension doesn't auto-generate an anchor prefix if the user provides one.

@jmooring
Copy link

those would be equivalent to the anchorlinenos (boolean) and lineanchor (string)

Yes, but Hugo is just one of several projects that leverage yuin/goldmark and yuin/goldmark-highlighting. Implementation details need to be somewhat agnostic with respect to downstream projects.

@kaushalmodi
Copy link
Author

Closing this issue here because the issue was apparently fixed in Hugo itself in gohugoio/hugo@08fdca9 .

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

No branches or pull requests

2 participants