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

LinkableLineNumbers doesn't respect WithClasses configuration #683

Closed
plumbis opened this issue Oct 9, 2022 · 1 comment · Fixed by #692
Closed

LinkableLineNumbers doesn't respect WithClasses configuration #683

plumbis opened this issue Oct 9, 2022 · 1 comment · Fixed by #692

Comments

@plumbis
Copy link

plumbis commented Oct 9, 2022

Describe the bug
When using both LinkableLineNumbers(true) and WithClasses(true) the html generated by LinkableLineNumbers always includes a style instead of a class for the style of the line number link.

https://github.com/alecthomas/chroma/blob/master/formatters/html/html.go#L353

To Reproduce
I think this can be reproduced with any code input:

wget http://www.google.com

But the Chroma CLI doesn't have a build with Linkable line numbers yet.

I think a full command would be:

chroma --lexer shell --formatter html --style monokai --html-lines --html-only --html-linkable-lines <source>

Here is the HTML output generated by Hugo demonstrating the problem

<table class="lntable"><tr><td class="lntd">
  <pre tabindex="0" class="chroma"><code><span class="lnt" id="1">
<a style="outline: none; text-decoration:none; color:inherit" href="#1"> 1</a>

Although the table and td elements have classes the a element has an inline style.

I apologize I don't know Golang so I can't test or submit a patch, but it looks like the style needs to be applied similar to highlighted lines here:
https://github.com/alecthomas/chroma/blob/master/formatters/html/html.go#L293

@alecthomas
Copy link
Owner

Thanks for the excellent bug report, this should be fixed in #692.

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.

2 participants