pygments
pygments copied to clipboard
HTML formatter: `nowrap` should not clobber `linenos=inline` option
Hi there, I noticed that using the HTML formatter with linenos=inline
and nowrap
is not possible with pygmentize
.
It seems like this shouldn't be the case because there's nothing about about the line numbers that justify needing to be wrapped in a pre
and div
tag. I'm writing a static site generator in Clojure that allows the user to interop with pygmentize
, but I don't want the outer pre
and div
elements in pygmentize
's output.
For example, Chroma allows the user to include inline line numbers without enclosing with a pre
: chroma --lexer=clojure --formatter=html --html-only --html-prevent-surrounding-pre --html-inline-styles --style=algol_nu --html-lines /tmp/foo.clj
I'd be happy to try to tackle this if it seems reasonable.
Minimal reproduction
foo.py
print("hi")
for x in range(5):
print(x)
❯ pygmentize -f html -O "nowrap,linenos=inline" -l python /tmp/foo.py
<span class="nb">print</span><span class="p">(</span><span class="s2">"hi"</span><span class="p">)</span>
<span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">5</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
Version
❯ pygmentize -V
Pygments version 2.12.0, (c) 2006-2022 by Georg Brandl, Matthäus Chajdas and contributors.