Open
Description
Context
When using the highlight
option to provide a custom syntax highlighter, markdown-it-py wraps the HTML output of the highlighter in <pre><code>
unless it already starts with <pre
:
markdown-it-py/markdown_it/renderer.py
Line 270 in 73a0147
But that heuristic fails for pygments.highlight
, whose output does not begin with <pre
:
>>> pygments.highlight('print("hello")', pygments.lexers.get_lexer_by_name("python"), pygments.formatters.HtmlFormatter())
'<div class="highlight"><pre><span></span><span class="nb">print</span><span class="p">(</span><span class="s2">"hello"</span><span class="p">)</span>\n</pre></div>\n'
So markdown-it-py turns this into <pre><code><div class="highlight"><pre>…</pre></div></code></pre>
, and existing CSS themes for Pygments need to be rewritten to account for the unnecessarily duplicated <pre>
.
Proposal
Can we have an option to skip adding <pre><code>
that’s not subject to the heuristic?
Tasks and updates
No response