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

Improves syntax highlight filter #325

Merged
merged 3 commits into from
Dec 19, 2019

Conversation

JuanitoFatas
Copy link
Contributor

@JuanitoFatas JuanitoFatas commented Dec 19, 2019

I recently upgraded a project from 3rd party syntax highlight filter to HTML::Pipeline::SyntaxHighlightFilter. Found the syntax highlight is not working anymore (missing highlight class from pre element. Fixed in dc42b12.

Hence opened this Pull Request ☺️

  1. Remove unused class assignment 2f7dc1b
  2. Fix css scope added to pre element dc42b12
  3. Improve documentations c594b66

Please let me know if the commit message does not explain well.

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".
@JuanitoFatas JuanitoFatas changed the title Improves Syntax highlight filter Improves syntax highlight filter Dec 19, 2019
@gjtorikian
Copy link
Owner

Thank you! Releasing this out as a bugfix now.

@gjtorikian gjtorikian merged commit 815ca89 into master Dec 19, 2019
@gjtorikian gjtorikian deleted the syntax-highlight-filter/unused-code-and-docs branch December 19, 2019 17:56
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 this pull request may close these issues.

2 participants