pygments / pygments.rb

💎 Ruby wrapper for Pygments syntax highlighter
MIT License
572 stars 141 forks source link

why don't we have the html structure consistent whatever line numbers present or not. #135

Closed vince-styling closed 3 years ago

vince-styling commented 10 years ago

Hi, i've an improvement suggest i think is was :), about the output html structure, may i explain what we has first? as you know, when we output without line numbers, the html structure like this :

<div class="highlight ruby"><pre><span class="nc">def</span>...</pre></div>

and if we enable to generate the line numbers, we'll get this :

<table class="highlight rubytable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3
4
5</pre></div></td><td class="code">
<div class="highlight ruby"><pre><span class="nc">def</span>...</pre></div>
</tr></table>

i think the best structure when we generating with line numbers should be this :

<div class="highlight ruby"><table><tr><td class="linenos"><pre>1
2
3
4
5</pre></td><td><pre><span class="nc">def</span>...</pre></tr></table></div>

by this way, we got the same root element either, which let's styling the root element effort never lose after we turn from non-line_numbers to line_numbers, all we should do in additional just add some css to make the table looks fine, and the root element's style change nothing, i believe it's more elegant.

slonopotamus commented 3 years ago

This is out of scope of this library. All markup is created by Pygments. Also, note that bundled Pygments version was updated in #205, so possibly markup have changed.