Skip to content

Newlines are lost during formatting #3285

Closed
@nrktkt

Description

@nrktkt

Describe the issue/behavior that seems buggy
Preformatted code is lost after highlighting a block in 11.1.
It seems that in version 10 br elements were inserted, and now they aren't. Although I don't know why that should matter in a pre block.

Sample Code or Instructions to Reproduce

I have a little library that uses highlight to embed source using web components.
https://kag0.github.io/sauce/
You can see on the documentation page, it's embedding snippets from an example html file in the repo https://kag0.github.io/sauce/example.html but they're missing the line breaks.

To prove that they would normally have line breaks:

  1. clone the repo
  2. open example.html and change the script embed from https://kag0.github.io/sauce/sauce.js to the local sauce.js
  3. open sauce.js and comment out line 43 .then(_ => hljs.highlightBlock(code))
  4. open example.html in the browser, observe that line breaks and indentation are correct
  5. uncomment the line and observe that code is highlighted, but line breaks are gone

Expected behavior
line breaks should be preserved

Additional context
rel
#2131
#3242

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions