-
Notifications
You must be signed in to change notification settings - Fork 743
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
Line highlighting like pygments hl_lines #264
Comments
Hi! This should be much easier after the formatter refactor for 2.0. |
I'm also interested in line highlights - is it worth a temp implementation before 2.0 is available? Happy to have a go and send a PR. |
Fix minor SCSS issues introduced in rouge-ruby#262.
Would love this as well.... |
Hello @jneen , first I want to say that Rouge seems to be a lot faster (when used from Ruby) than the old Pygments option. It will be great if you can implement the hl_lines option. I've just migrated from an older Jekyll version that was using Pygments to the latest Jekyll which uses Rouge and half of my posts are broken because of this feature missing. Thanks, |
I went ahead and tried to implement this, but hit a problem with line numbering. The HTMLTable formatter, which provides table-based line numbering, delegates to the wrong method on the inner formatter. Instead of delegating to the stream method, it delegates to the span method. This makes it impossible to put a line-wise formatter in between the HTMLTable and HTML formatter. If it delegated to the stream method instead, it would work. I'll open an issue to address this. Once fixed, I can submit an HTMLHighlightLines formatter (like Pygments). |
See #1083. |
Also related is #1084, which is 80% of what is needed for the linewise highlighter. |
This issue has been automatically marked as stale because it has not had any activity for more than a year. It will be closed if no additional activity occurs within the next 14 days. If you would like this issue to remain open, please reply and let us know if the issue is still reproducible. |
The related issues have been addressed, so I'll see if I can dig up my patch and submit it. |
- add line highlighting option to HTMLLinewise formatter - add dedicated formatted to add line highlighting (only mark highlighted lines)
- add line highlighting option to HTMLLinewise formatter - add dedicated formatter to add line highlighting (only marks highlighted lines)
I submitted a PR (#1426). In the PR, I'm proposing both a new formatter (HTMLLineHighligher) and an enhancement to the HTMLLinewise formatter. The difference is that the HTMLLineHighlighter only wraps the lines specified by the highlight_lines option, whereas the HTMLLinewise formatter wraps all lines (as it currently does) and only adds the additional highlight line class to the highlighted lines. If you think the additional formatter is unnecessary, I can remove it. |
Since Rouge works in the API space, I felt it was most appropriate for the option ( |
- add line highlighting option to HTMLLinewise formatter - add dedicated formatter to add line highlighting (only marks highlighted lines)
- add line highlighting option to HTMLLinewise formatter - add dedicated formatter to add line highlighting (only marks highlighted lines)
I'm looking for the ability to highlight lines, either to call attention to specific code in a tutorial, or note added code in a running example.
Pygments offers the hl_lines option, such as hl_lines="3 4 5". This adds span element w css class of "hll" to the generated html for that line.
Is this something that has been talked about or planned?
The text was updated successfully, but these errors were encountered: