WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 15 months ago

Last modified 13 months ago

#18807 closed defect (bug) (fixed)

Switching from HTML to Visual messes up "samp" elements

Reported by: jsumners Owned by: azaozz
Milestone: 3.6 Priority: normal
Severity: normal Version: 3.2.1
Component: Editor Keywords: has-patch
Focuses: Cc:

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)

18807.samp-is-not-a-block-element.patch (1.0 KB) - added by toscho 15 months ago.
remove samp from block elements
18807.samp-no-block-2.patch (2.0 KB) - added by toscho 15 months ago.
remove samp from block list in js and php
18807.samp-fix-3.patch (2.9 KB) - added by toscho 15 months ago.
3rd attempt to fix samp

Download all attachments as: .zip

Change History (21)

comment:1 nacin2 years ago

  • Keywords needs-patch added

comment:2 jsumners2 years ago

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.

comment:3 nacin2 years ago

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.

comment:4 azaozz2 years ago

This seems to be a TinyMCE bug. It seems to treat <samp> as a block for some reason.

toscho15 months ago

remove samp from block elements

comment:5 toscho15 months ago

  • 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: SergeyBiryukov15 months ago

  • Milestone changed from Awaiting Review to 3.6

Introduced in [17625] for the JS version and [21888] for the PHP version.

Needs to be removed from the JS version as well then.

toscho15 months ago

remove samp from block list in js and php

comment:7 in reply to: ↑ 6 toscho15 months ago

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.

comment:8 in reply to: ↑ 6 ; follow-up: azaozz15 months ago

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?

comment:9 in reply to: ↑ 8 ; follow-up: toscho15 months ago

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 jsumners15 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 SergeyBiryukov15 months ago

  • Keywords commit added

comment:12 nacin15 months ago

Did this break when combined with the 3.5 TinyMCE schema changes?

comment:13 SergeyBiryukov15 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.

toscho15 months ago

3rd attempt to fix samp

comment:14 follow-up: toscho15 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 azaozz15 months ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In 23327:

Autop: <samp> is not a block tag, props toscho, fixes #18807

comment:16 in reply to: ↑ 14 azaozz15 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 ocean9015 months ago

#23375 was marked as a duplicate.

comment:18 toscho13 months ago

#23858 was marked as a duplicate.

Note: See TracTickets for help on using tickets.