pypa / readme_renderer

Safely render long_description/README files in Warehouse
Apache License 2.0
158 stars 88 forks source link

feat: preserve language attribute for code blocks #247

Closed miketheman closed 1 year ago

miketheman commented 2 years ago

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