HTML formatter: `nowrap` should not clobber `linenos=inline` option
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.2k
- Forks
- 885
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the shown pygmentize command using the HTML formatter and the nowrap,linenos=inline options. Trace the formatter's handling of those options; done means inline line numbers remain in the output without the surrounding pre and div elements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100