Improves syntax highlight filter#325
Merged
Merged
Conversation
The class of pre element was a legacy behavior. The Rouge formatter (ouge::Formatters::HTMLLegacy) used to wrap the highlight inside a `div`. The current formatter (`Rouge::Formatters::HTML`) we’re using does not do this any more. Also confirm with the code blocks behavior from Commonmark spec[1] and GitHub flavored spec[2] do not add class attribute to pre element. Hence the node here does not have class to set here. [1] https://spec.commonmark.org/0.29/#fenced-code-blocks [2] https://github.github.com/gfm/#fenced-code-blocks
If we generate a theme from Rouge: `Rouge::Themes::MonokaiSublime.render`, by default it scope
under .highlight:
```
.highlight table td { padding: 5px; }
...
.highlight .o { color: #f92672; }"
```
So we need to add highlight class to pre element.
If a user would like to scope under .code, then the context also needs change the generated highlight class for lang: "code code-css" instead of "code highlight-css".
Owner
|
Thank you! Releasing this out as a bugfix now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I recently upgraded a project from 3rd party syntax highlight filter to
HTML::Pipeline::SyntaxHighlightFilter. Found the syntax highlight is not working anymore (missinghighlightclass frompreelement. Fixed in dc42b12.Hence opened this Pull Request☺️
Please let me know if the commit message does not explain well.