Opened 9 years ago
Last modified 5 years ago
#34994 new defect (bug)
HTML5 elements reformatted poorly switching between Visual & Text editors
Reported by: | kristarella | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Formatting | Keywords: | |
Focuses: | administration | Cc: |
Description
HTML5 elements get reformatted in weird ways when switching between Visual and Text (HTML) editors.
Details tag (not fully supported in browsers yet, but still shouldn't receive this behaviour IMO) gets an additional above and below it upon each switch.
Section, article, and aside are all completely stripped of white space. This combined with the stripping of paragraph tags results in a block of run-together text within a couple of switches.
I used HTML5 elements from https://www.tinymce.com/docs/demo/format-html5/ to test with.
Note: See
TracTickets for help on using
tickets.
Hi @kristarella, thanks for the bug report.
This is a bug in wpautop() (both JS and PHP versions). It doesn't deal well with "block" tags that can contain other blocks when there are paragraphs in them.
Wpautop works by replacing two new lines with a
<p>
and one new line with a<br>
. If you type any new lines just before or after the start/end block tags (like your example for<details>...</details>
) wpautop may get "confused" and try to insert<p>
where they don't belong. Then on switching back to the Text editor, there extra<p>
are replaced with more line breaks.The section, article, and aside tags are not processed by wpautop specifically. That's why they remain on the same line. This behaviour keeps them working relatively well when switching Text => Visual => Text. These tags should generally be avoided in the post content as they are used in many themes and having them in the posts would be improper use/nesting in many cases.