-
Notifications
You must be signed in to change notification settings - Fork 794
Open
Labels
bugfix-requestA request for a bugfix to be developed.A request for a bugfix to be developed.
Description
Describe the bug
HTMLTable currently appends an extra newline to the formatted code if the last token does not end with \n. This behavior can be problematic when an HTMLLineHighlighter is used as it's @inner. Since HTMLLineHighlighter always appends a newline to the formatted output, which is not reflected in the input tokens. This results in two \ns to be inserted and an extra empty line.
To Reproduce
Steps to reproduce the behavior:
I originally stumbled upon this problem when using Jekyll with something like:
{% highlight plaintext linenos mark_lines="1" %}
foo
bar
{% endhighlight %}
{% highlight plaintext linenos %}
foo
bar
{% endhighlight %}Which produced (using a custom theme):

Expected behavior
I expected the first code block to not include the last empty line. like:

Possible fixes
Either:
- Make HTMLLineHighlighter not append an extra
\nafter the last line. - or make HTMLTable append the
\nonly when the formatted output of@innerdoes not end with a new line:I can confirm this solution solved my specific problem and have created a pull request.unless last_val && last_val.end_with?(?\n) num_lines += 1 formatted << ?\n unless formatted.end_with?(?\n) end
System:
- Ruby version 3.4.7
- Rouge version: 4.6.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugfix-requestA request for a bugfix to be developed.A request for a bugfix to be developed.