Skip to content

[Bug]: Extra Newline When Highlighting Specific Lines #9807

Open
@damned-me

Description

@damned-me

Operating System

Linux 9fe7e33eef81 6.8.0-1020-raspi #24-Ubuntu SMP PREEMPT_DYNAMIC Sun Feb 23 08:39:32 UTC 2025 aarch64 GNU/Linux

Ruby Version

ruby 3.3.8 (2025-04-09 revision b200bad6cd) [aarch64-linux]

Jekyll Version

jekyll 4.4.1

GitHub Pages Version

No response

Expected Behavior

I'm trying out the new Marking Specific Lines feature. I would expect the generated HTML to match the output of an equivalent non-highlighted input, except for the addition of the span element that applies the hll class.

Current Behavior

Currently Jekyll is using Rouge::Formatters::HTMLLineHighlighter, that by default adds a newline at the end of every processed line. This results in a trailing newline that breaks element alignment.

For a more detailed explanation of the issue and a proposed fix, please refer to the following issue.

Relevant log output

Code Sample

Steps to reproduce the issue

Rendering the following code is sufficient to reproduce the output shown in the screenshot. For context, I'm using the Minima v3 theme along with the GitHub highlight css.

{% highlight ruby linenos mark_lines="2" %}
def foo
  puts 'foo'
end
{% endhighlight %}

{% highlight ruby linenos %}
def foo
  puts 'foo'
end
{% endhighlight %}

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    has-pull-requestSomebody suggested a solution to fix this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions