Single empty line breaks are ignored
See original GitHub issueI’m rendering some markdown line so:
import auth from '@react-native-firebase/auth';
import database from '@react-native-firebase/database';
async function onCreateAccount() {
// Get the users ID
const uid = auth().currentUser.uid;
// ..
The rendering works fine, however there is no line break happening between the imports/function:
It looks like the line token plain
child is an empty string, rather than a string with a single space. I’m able to get around this by doing:
<code>
{tokens.map((line, i) => {
// Ensure blank lines/spaces drop onto a new line
if (line.length === 1 && line[0].content === '') {
line[0].content = ' ';
}
return (
<div {...getLineProps({ line, key: i })}>
{line.map((token, key) => {
Not sure if it’s a bug or something my end? There doesn’t seem to be an issue when it’s already within a line.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:7
Top Results From Across the Web
Ignore double \newline on page break - LaTeX Stack Exchange
I am new to Latex, but it seems to me that people don't want to leave empty lines between paragraphs, but just have...
Read more >Do all browsers ignore blank lines in html - Stack Overflow
Line returns in the HTML document are ignored. ... Line breaks are displayed, however, when text is tagged as preformatted text ( <pre>...
Read more >Line breaks and blank spaces - Overleaf, Online LaTeX Editor
As you can see, single line break in the code acts as a space in text. However, leaving an empty line starts a...
Read more >Remove empty lines and Line Breaks in text — oracle-tech
So to remove empty lines means replacing 2 sets of line breaks directly after one another, with a single set. E.g..
Read more >rule-empty-line-before - Stylelint
This rule ignores rules that are the very first node in a source. The fix option can automatically fix all of the problems...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had a similar issue and the solution by @Ehesp fixed it for me. I think this is not in this library yet. See when I use the following markdown:
I get rendered what I wished for:
But when I copy and paste the code to my editor/IDE, I get:
without the line break. I can see it also on my blog that there is nothing “selected” as line in between:
However, when I use the solution by @Ehesp with:
it preserves the empty line when copy and pasting the code and it also shows it as something “empty” selected on my blog:
I guess more people have this problem without noticing. Just wanted to mention it here again and thank @Ehesp 👍
Following the instructions here I was getting an empty line at the end of all of my code blocks:
To fix this, I modified this part of the example code:
And I added a
.filter()
to remove empty lines:And this seemed to do the trick:
Hope this helps someone.