#18807 closed defect (bug) (fixed)
Switching from HTML to Visual messes up "samp" elements
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.6 |
| Component: | Editor | Version: | 3.2.1 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | info@… |
Description
Type the following into the HTML editing view of a new post:
This is an example: <samp>/tmp/some.file</samp>. More text.
Now, switch to the Visual editing view and you will get:
This is an example: /tmp/some.file . More text.
The "samp" element should be treated exactly like the "code" element. See http://www.w3.org/TR/html5/text-level-semantics.html#the-samp-element for more information on the samp element.
Attachments (3)
Change History (21)
The ticket needs a patch. It doesn't need to come from you necessarily, though it may speed up acceptance. I forget where all of the moving bits are here myself, otherwise I probably would have patched it as well.
This seems to be a TinyMCE bug. It seems to treat <samp> as a block for some reason.
- Cc info@… added
- Keywords has-patch added; needs-patch removed
This is not (just) a TinyMCE bug, samp is part of the block element list in wpautop().
The attached patch removes samp from the list of block elements.
Please set the milestone to 3.6; I just had to hack around this bug in a long document with many string examples.
comment:6
follow-ups:
↓ 7
↓ 8
SergeyBiryukov — 4 months ago
- Milestone changed from Awaiting Review to 3.6
Replying to SergeyBiryukov:
Introduced in [17625] for the JS version and [21888] for the PHP version.
Needs to be removed from the JS version as well then.
Done. Thanks for finding this.
Yes, currently <samp> accepts only phasing content. Looking for the reason it was added to the blocklists, perhaps it was accepting "flow" content at the time?
Replying to azaozz:
Looking for the reason it was added to the blocklists, perhaps it was accepting "flow" content at the time?
It was always an inline element.
comment:10
in reply to:
↑ 9
jsumners — 4 months ago
Replying to toscho:
Replying to azaozz:
Looking for the reason it was added to the blocklists, perhaps it was accepting "flow" content at the time?
It was always an inline element.
Exactly. It makes no sense why this was ever part of the block elements list.
comment:11
SergeyBiryukov — 4 months ago
- Keywords commit added
comment:12
nacin — 4 months ago
Did this break when combined with the 3.5 TinyMCE schema changes?
comment:13
SergeyBiryukov — 4 months ago
- Keywords commit removed
I can reproduce the original report in 3.2 and 3.6-alpha-23288.
Found an issue with the patch though: the space between example: and <samp> disappears when switching to Visual editor:
This is an example:<samp>/tmp/some.file</samp>. More text.
If I replace <samp> with <code>, the space is preserved:
This is an example: <code>/tmp/some.file</code>. More text.
comment:14
follow-up:
↓ 16
toscho — 4 months ago
Hm, I missed one in wp-tinymce-schema.js. Why are these lists spread over several files? wpautop() and TinyMCE should use the same source for formatting.
comment:15
azaozz — 4 months ago
- Owner set to azaozz
- Resolution set to fixed
- Status changed from new to closed
In 23327:
comment:16
in reply to:
↑ 14
azaozz — 4 months ago
Why are these lists spread over several files?
We can sync the blocklists for the JS and PHP wpautop, however tinymce-schema.js is an internal part of TinyMCE.
comment:17
ocean90 — 3 months ago
#23375 was marked as a duplicate.
comment:18
toscho — 8 weeks ago
#23858 was marked as a duplicate.

I can't find any information on what the keywords mean. Does the "needs-patch" keyword mean that I need to submit a patch? If so, I wanted to do so when I created the ticket, but I was unable to figure out where the "code" element is being applied so that I could add in a check for the samp element.