Avoid duplicated output using highlight tags #2264
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
This tiny patch fixes a bug while using Rouge with
highlight
tags. The output was duplicated since theoutput
variable in the Liquid tag definition was equal to the highlighter's prefix value and the<<
method changes its receiver.Therefore, we should simply define an empty string and append the prefix if it is present.
I noticed that this is only happening with posts (not index.html for instance).
I did not manage to write a failing test though so I wrote a feature (see this gist ; let me know if I'm doing something wrong). The assertion is also a bit tricky/brittle ; let me know if you have a better idea to ensure that there is only a single
.highlight
div.There are also other pull requests about this area of the code (i.e. #2221 and #2154) but I don't know which one you are going to ship and Jekyll 2.0 is already at the release candidate step so I take the liberty to send the proper fix here.
Have a nice day.