Open janboddez opened 3 weeks ago
Note that while this is ugly code, the <br />
s would never actually end up in the post content. (And neither would any literal <br />
s, like from code examples ...)
(But who uses
<br />
anymore?)
I guess we could always use a more unique "pattern" or something. But I just really wish Firefox (in my case) would leave the line breaks intact. Like, it works fine when I do console.log( window.getselection() )
on the page itself but not when in the bookmarklets.js
script I retrieve the text. At that point, no line breaks.
Right now, we do
URIComponent( window.getSelection()?.replace( /(?:\r\n|\r|\n)/g, '<br />' ) )
.This converts newline chars to
<br />
, and then on the "receiving end" we convert the<br />
s back to ... paragraphs, actually.I did this because without it, my browser (?) would strip the newline chars and paragraphs would get stuck together, which isn't great.
Only downside with the current approach is that literal instances of
<br />
(in the selected text) also get converted to a new line, or rather, start a new paragraph. (But who uses<br />
anymore?)