rouge-ruby / rouge

A pure Ruby code highlighter that is compatible with Pygments
https://rouge.jneen.net/
Other
3.33k stars 735 forks source link

diff lexer incorrectly adds error color #1850

Closed redonkulus closed 2 years ago

redonkulus commented 2 years ago

Name of the lexer diff

Code sample

<div>
- <span></span>
+ <p></p>
</div>

output

<code id="parse_code"><span class="gd">&lt;div&gt;
- &lt;span&gt;&lt;/span&gt;
</span><span class="gi">+ &lt;p&gt;&lt;/p&gt;
</span><span class="gd">&lt;/div&gt;</span></code>

Sample: http://rouge.jneen.net/v3.29.0/diff/PGRpdj4KLSA8c3Bhbj48L3NwYW4-CisgPHA-PC9wPgo8L2Rpdj4

Additional context

The first line in this diff gets included in the "substracted" part of the diff (i.e, wrapped in <span class="gd">), when it should not be included. This causes the diff to look like more is being removed than necessary.