-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Newlines are lost during formatting #3285
Comments
Not sure what I'm looking at. All the examples look fine to me here in Safari.
|
You may also want to look at |
Sorry about that, I had pinned However, following the reproduction steps I outlined should still have demonstrated the issue.
If you inspect the code snippets, you should see them in |
ah hah! That did indeed make the difference. Thank you! |
Nothing to do with us, the two DOM APIs are subtly different in their behavior. I'm not aware of why this should have changed from version 10 to version 11 though.
https://stackoverflow.com/questions/35213147/difference-between-textcontent-vs-innertext |
Glad to help. Closing issue. |
Could we at least document for folks in the future that if they programmatically populate their blocks, they need to use
I don't think it did exactly, 10 just added
|
It really depends on what you are trying to do. There are uses for the different APIs, that's why they each exist... knowing how to user the DOM API is kind of outside the scope of using HLJS. Perhaps you could create a wiki page though ? I'm not sure where else we'd document that as I'm not sure it's actually super relevant for many users (and our README is already quite long). I thought of FAQ, but this isn't really a FAQ either (IME)... did you have a specific suggestion?
Only if use used the |
Just walked right into this one. I guess the existence of this issue is documentation in itself. Regarding FAQ: I don't know how often a question needs to arise in order to make it into FAQ, but it seems that multiple people have encountered this, or something related, in #1664 I agree that how to use the DOM API is outside the scope of using HLJS and its documentation. However, people will continue opening Github issues for this in HLJS, because it's not obvious right away that it's DOM misuse. Having in the FAQ "before you create a github issue about missing highlights due to comments, or broken line breaks, or whitespace issues, or anything else, make sure you know the difference between innerText and textContent, and are using the latter" - that would at least prevent people from opening new Github issues for this project. |
I would love to see this information here: This one phrase would have saved me a lot of time. Edit: My code did use |
Were you using |
No. |
What exactly was the issue with your linebreaks then, do you recall? |
|
If you check the browse console you'll see tons of errors/warnings. Perhaps we could make a more specific error for using |
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 apre
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:
example.html
and change the script embed fromhttps://kag0.github.io/sauce/sauce.js
to the localsauce.js
sauce.js
and comment out line 43.then(_ => hljs.highlightBlock(code))
example.html
in the browser, observe that line breaks and indentation are correctExpected behavior
line breaks should be preserved
Additional context
rel
#2131
#3242
The text was updated successfully, but these errors were encountered: