Skip to content

Improves syntax highlight filter#325

Merged
gjtorikian merged 3 commits into
masterfrom
syntax-highlight-filter/unused-code-and-docs
Dec 19, 2019
Merged

Improves syntax highlight filter#325
gjtorikian merged 3 commits into
masterfrom
syntax-highlight-filter/unused-code-and-docs

Conversation

@JuanitoFatas

@JuanitoFatas JuanitoFatas commented Dec 19, 2019

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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