[wp-trac] [WordPress Trac] #33712: Press This: Multiple paragraphs in source text are quoted as a single paragraph
WordPress Trac
noreply at wordpress.org
Thu Dec 24 04:43:30 UTC 2015
#33712: Press This: Multiple paragraphs in source text are quoted as a single
paragraph
--------------------------+------------------------------
Reporter: rachelmcr | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Press This | Version: 4.2
Severity: normal | Resolution:
Keywords: needs-patch | Focuses: javascript
--------------------------+------------------------------
Comment (by azaozz):
There are two ways this can be done:
- We can make "pseudo" paragraphs. `window.getSelection().toString()`
returns the text with line breaks which follow the visible layout. We can
replace `\n\n` with `<p>` and `\n` with `<br>`, or just run it through
wpautop(). This will approximate the original layout but will not use any
of the HTML, so if there is a link in the selection, only the linked text
will be shown. The advantage is that this will produce very clean,
minimal, safe HTML from the selection.
- We can get the selected range and "extract" the HTML. This will bring
all sorts of tags and attributes, so will have to run it through pretty
restrictive kses filter. In many cases this will also contain divs which
don't work well in the editor. At first look this seems better, but the
selection will have to be filtered/cleaned quite a lot to make it suitable
for the editor.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/33712#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list