Skip to content

Shows some extra new lines for pre tags #132

@gmoniava

Description

@gmoniava

I am having some problems with this library and pre tags.

See this usage from my project:

const highlightedHTML = highlight(codeString).replace(/\n/g, "");

I added that replace because it was showing some extra empty horizontal lines inside pre tags, like this:

Image

If I keep that replace used above, it actually fixes the problem in development mode and the extra space between the lines as shown above is gone but now in production, it shows:

Image

Can you please have a look? Are those extra lines default behavior? and how to remove them such that it works ok both in dev and prod?


It seems the reason why replace fixed the problem in development mode was related to this element:

<span class="sh__token--string" style="color: var(--sh-string)">
</span>

This span was usually present as a child (one before the last) under each sh__line span. And this element causes empty horizontal line too. So when there was this element but no replace there were two empty horizontal lines. And using replace as mentioned above, reduced those empty lines to one. That's why it worked in development.

Strangely, in production, this element is not rendered. And using replace removes the one remaining empty line too. Which explains why in production mode everything was on single line like in the second screenshot.

UPDATE: this span element is present on Windows, not on Ubuntu (in developmemt mode).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions