Allow marking specific highlighted lines via Liquid#9138
Allow marking specific highlighted lines via Liquid#9138jekyllbot merged 15 commits intojekyll:masterfrom
Conversation
2bd03cc to
928f558
Compare
|
Thank you for submitting this proposal, @lylo. |
Good spot, thanks @ashmaroli. I've updated this in 7cfd1fa |
|
Hey 👋 I just wondered whether there was anything I could do to push this PR forward, or is it just a matter of waiting for someone on core to find it and take a look? |
|
I could have sworn we had this feature like 8 years ago. Was it a Pygments-only feature that Rouge only recently included? |
|
@lylo Pinging you to inform you that this enhancement will land in the next minor release (v4.4.0). |
|
Thanks @ashmaroli 🙏 |
parkr
left a comment
There was a problem hiding this comment.
LGTM. One quick comment about testing the class customization.
|
@lylo Thank you for adding the new features. Needs some minor edits:
Since you mentioned "succinct", I would like to request you to make the following change to cucumber scenarios you have added:
|
|
P.S. to above comment 👆: |
|
Why have you renamed the sample file to "test.rb" from "index.html"? |
You can ignore that, it was reverted in a later commit |
|
Buddy, you have made things harder for yourself by cherry-picking my commit from the Locally run in terminal: |
|
@ashmaroli I have a clean branch locally I can put a fresh PR up for if you prefer. I think that would be best in this circumstance, but I'll defer to you. Apologies for the additional work I've created here. |
Fixed in 03a68ea
I've addressed this in 289421a by relaxing the rules of the parser. So while the correct format for declaring {% highlight ruby highlight_lines="1 2" highlight_line_class=one_two %}This change will be forgiving and do the expected thing if somebody did try and pass in a double-quoted list of integers, so this: {% highlight ruby highlight_lines="1 2" highlight_line_class="1 2" %}Will result in a class name of I'm happy to be less forgiving and raise a syntax error instead if you prefer. The main problem I'm having here is the overarching strict parsing rules and regexes. It could really do with a full overhaul. I'm just trying to work within it's constraints. |
|
@lylo Found multiple issues with the latest implementation. I guess you couldn't give 100% focus into this due to the various moving parts and inputs from my end. I therefore took the liberty of cleaning the branch up directly instead of first pointing out all the issues. |
|
@parkr Requesting a fresh round of review on this pull request. Thanks. |
|
Hello @lylo, It just dawned on me that there's a possibility that users may get confused by the proposed line-highlighter parameter names. Tl;drCan you think of better prefixes for the new proposed options? DetailsThe tag itself is named My brain came up with using |
|
@ashmaroli I used If we're avoiding Happy to change to one of these if you agree? |
|
@lylo I understand your perspective and that the current implementation is simpler because of it. I guess we will have to settle for |
parkr
left a comment
There was a problem hiding this comment.
LGTM. I don't have a strong opinion on the naming – whatever you feel is best for a non-technical user. Thanks!
lib/jekyll/tags/highlight.rb
Outdated
| #{markup} | ||
|
|
||
| Valid syntax: highlight <lang> [linenos] | ||
| Valid syntax: highlight <lang> [linenos] [highlight_lines="3 4 5"] [highlight_line_class=class_name] |
There was a problem hiding this comment.
Is there a strong reason to customize the highlight line class? Couldn't a user simply apply the styles they want to .hll?
There was a problem hiding this comment.
I was having the same thought today! I think we should remove this option for the time being. If we find it's a problem for people in the future, we can always add it. Feels like a premature optimisation right now.
I'll fix.
|
|
||
| Valid syntax: highlight <lang> [linenos] | ||
| Valid syntax: highlight <lang> [linenos] [highlight_lines="3 4 5"] [highlight_line_class=class_name] | ||
| MSG |
There was a problem hiding this comment.
Could be an interesting opportunity to link out to the jekyllrb.com page for this tag so users have a direct line to a helpful webpage with more information on the matter.
It's no problem, I'm enjoying the journey and learning a lot. In 8a202c5 I've changed this to |
|
Thank you @lylo. @jekyllbot: merge +minor |
|
@jekyllbot: merge +minor |
Olly Headey: Allow marking specific highlighted lines via Liquid (#9138) Merge pull request 9138
Hey @ashmaroli, do you mean changing from: Rouge::Formatters::HTMLTable.new(
formatter,
:css_class => "highlight",
:gutter_class => "gutter",
:code_class => "code"
)to: Rouge::Formatters::HTMLTable.new(
formatter,
css_class: "highlight",
gutter_class: "gutter",
code_class: "code"
) |
|
@lylo I did mean that, but I have already made the changes to |
The use of `mark_lines` in the `highlight` liquid tag is merged, but not yet released. (See jekyll#9138). It took me some digging to work out why it wasn't working ;) I'm not sure if this is the correct approach, but this PR tags the feature as released in the upcoming `4.4.0` release...
…l#9138, is merged but not yet released. The docs on the live site have been updated to reflect this new, but unreleased functionality: https://jekyllrb.com/docs/liquid/tags/#marking-specific-lines. This could be confusing to people... it took me some digging to work out why it wasn't working ;) I'm not sure if this is the correct approach, but this PR tags the feature in the docs as requiring the upcoming `4.4.0` release...
This is a 🙋 feature or enhancement.
Summary
Support for highlighting lines of code was added to Rouge in rouge-ruby/rouge@d7b60c0. This PR adds support to Jekyll for this feature.
Resolves #8621 (albeit partially)