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

feat: preserve language attribute for code blocks #247

Merged
merged 4 commits into from Jul 19, 2022

Conversation

miketheman
Copy link
Member

@miketheman miketheman commented Jul 13, 2022

As surfaced in #200, we were stripping away the lang attribute in the resulting <pre> blocks.

While GitHub's UI may add more tags/behaviors based on their syntax highlighting rendering engine, at the very least we can try to preserve the lang attribute after we run our pygments syntax highlighter.

This change doesn't conform 100% to the GFM output on GitHub, as they apply another form of syntax highlighting to the HTML that removes the lang attribute from known languages after being highlighted. I don't know yet which process they use for that.

Resolves #200

Signed-off-by: Mike Fiedler miketheman@gmail.com

miketheman and others added 4 commits July 13, 2022 12:15
Signed-off-by: Mike Fiedler <miketheman@gmail.com>
In order to allow the `lang` attribute on `pre` code blocks, add it to
the post-syntax highlighting step, and then allow through the sanitizer.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
Signed-off-by: Mike Fiedler <miketheman@gmail.com>
@di di merged commit de0162a into pypa:main Jul 19, 2022
@miketheman miketheman deleted the miketheman/preserve-lang-attribute-200 branch July 19, 2022 16:13
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.

preserve lang attribute in <pre> codeblocks
2 participants