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

Commits on Dec 19, 2019

  1. Remove unused code

    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
    JuanitoFatas committed Dec 19, 2019
    Configuration menu
    Copy the full SHA
    2f7dc1b View commit details
    Browse the repository at this point in the history
  2. Generated class should also be under scope

    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 committed Dec 19, 2019
    Configuration menu
    Copy the full SHA
    dc42b12 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c594b66 View commit details
    Browse the repository at this point in the history