Single line break should not be converted to paragraph
See original GitHub issueHello, I’ve just installed this converter and I’ve found an issue. How do I prevent single line breaks to being turned into new paragraphs?
Right now writing
Example Text\n
Second Line
gets turned into
<p>Example Text</p><p>Second Line</p>
whereas the result I expect should be
<p>Example Text<br>Second Line</p>
Two consecutive line breaks instead should be turned into a new paragraph.
Any ideas on how I could achieve this?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:5
Top Results From Across the Web
The Secret To Converting Paragraph Breaks Into Line Breaks ...
Convert Paragraph (Or Line Break) Lists To A Comma Separated List · Use CTRL + H to bring up the Find and Replace...
Read more >Is it possible to convert paragraph breaks in Word to line ...
With the code as a single paragraph I only need to set the style on any point for it all to be covered,...
Read more >Converting new lines to paragraph/br HTML tags, can this be ...
First, replace the case when there are two line breaks. to = to.replace(/\n{2}/g, ' </p><p> ...
Read more >The Dos and Don'ts of Adding an HTML Line Break
The HTML line break element can be used to display poems, song lyrics, ... The first uses one paragraph element and multiple line...
Read more >Understanding paragraphs and line breaks in WordPress
Hitting the Enter (Return) key will end the paragraph you are writing and start a new one. If you want to start a...
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 Free
Top 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
This should be the default behaviour. However DraftJS out of the box doesn’t ship with
handling of newlines like you’d expect. The default is a new paragraph (which mirrors Microsoft Word etc.). Try this in your Editor
Hey — thanks, that makes a lot of sense. I’m using DraftJS-convert in the Mailspring email client so I probably have unusual goals—basically need to get HTML that exactly visually matches what the user typed so the editor seems WYSWIG. Here’s the config I ended up using which (at least so far) seems to maintain whitespace reliably and still be read back into DraftJS correctly via
convertFromHTML
: