-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Svelte trims content for <pre> #6437
Comments
Check out this REPL |
This is a perfect fix! I wonder why this isn't the default behavior, though. Does someone mind shedding some light on this? Bug or feature? |
it's interesting that simple empty span fix trimming. I saw already similiar bug with more ifs in row, where adding one space in code fixed padding by 200px. |
Fixed in 3.46.4 - https://svelte.dev/repl/829574eb0d814385b6842c7a4ba000dc?version=3.46.4 |
This took me a bit by surprise on my site (I updated too many packages at once so I didn't realise it was due to Svelte). My mistake since I was relying on the non-standard behaviour by doing this: <pre class="{`prism language-${lang}`}" tabindex="0">
<code class=prism>{@html code}</code>
</pre> Switching to this solves it (and it is how it should be I guess?): <pre
class="{`prism language-${lang}`}"
tabindex="0"
><code class=prism>{@html code}</code></pre> Only one detail. Svelte seems to be adding an extra whitespace when there's a new line at the beginning when this does not happen using plain HTML unless there's an explicit white space after the |
…tejs#6990) Fixes sveltejs#6437 Fixes sveltejs#4731 Closes sveltejs#4737 Whitespace is now untouched inside <pre> tag and other tags if preserveWhitespace is true
…tejs#6990) Fixes sveltejs#6437 Fixes sveltejs#4731 Closes sveltejs#4737 Whitespace is now untouched inside <pre> tag and other tags if preserveWhitespace is true
…tejs#6990) Fixes sveltejs#6437 Fixes sveltejs#4731 Closes sveltejs#4737 Whitespace is now untouched inside <pre> tag and other tags if preserveWhitespace is true
…tejs#6990) Fixes sveltejs#6437 Fixes sveltejs#4731 Closes sveltejs#4737 Whitespace is now untouched inside <pre> tag and other tags if preserveWhitespace is true
…tejs#6990) Fixes sveltejs#6437 Fixes sveltejs#4731 Closes sveltejs#4737 Whitespace is now untouched inside <pre> tag and other tags if preserveWhitespace is true
Describe the bug
Considering specs "pre" should display content as is, https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre
But Svelte trims content
To Reproduce
https://svelte.dev/repl/829574eb0d814385b6842c7a4ba000dc?version=3.38.3
The text was updated successfully, but these errors were encountered: