question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pre-formatted text loses line breaks

See original GitHub issue

Pre-formatted text loses line breaks

Multi-line text inside a <pre> block seems to loose line breaks.

Your environment

Steps to reproduce

On any markdown file, just add the following:

<pre>
line 1
line 2
</pre>

Expected behaviour

Expected rendered HTML to be:

<pre>
line 1
line 2
</pre>

Actual behaviour

Rendered HTML is:

<pre>line 1 line 2</pre>

So line breaks are missing!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
derekmcommented, Nov 15, 2021

Thanks, @wooorm!

I figured it out:

import versions from '@site/versions';
<pre><code>
{`wget https://github.com/pravega/pravega/releases/download/v${versions.pravega}/pravega-${versions.pravega}.tgz
# or
#curl -OL https://github.com/pravega/pravega/releases/download/v${versions.pravega}/pravega-${versions.pravega}.tgz
tar zxvf pravega-${versions.pravega}.tgz
cd pravega-${versions.pravega}`}
</code></pre>

Note the quoting expression:

{`...
...
...`}

and the $ on the bracketed variable substitutions (${...} instead of {...}).

Assuming a versions.js of:

const versions = Object.freeze({
  "pravega": "0.10.1",
});

export default versions;
2reactions
wooormcommented, Jun 5, 2020

Yes it matters. MDX is JSX first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Line breaks are removed in posts made in plain text format
Method 1 - Disable the feature that removes extra line breaks · Open Outlook. · On the Tools menu, select Options. · On...
Read more >
Pasting into prefotmatted box removes line breaks - Jira
Issue Summary. When copying some texts into a preformatted box, in some situations it removes the line breaks. Steps to Reproduce.
Read more >
Losing line break when displaying text - Stack Overflow
Use the pre tag and the new lines will be respected. pre is for preformatted text and will use non-proportional font so it...
Read more >
How to Preserve Newlines, Line Breaks, and Whitespace in ...
For example, a text from a textarea may contain line breaks or empty lines. The white-space CSS property is helpful displaying the text...
Read more >
Using Preformatted Text | Working with Text in HTML5 - Peachpit
The pre element is ideal for text that contains important spaces and line breaks, like the bit of CSS code shown here. Note,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found