Make WordPress Core

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#18807 closed defect (bug) (fixed)

Switching from HTML to Visual messes up "samp" elements

Reported by: jsumners's profile jsumners Owned by: azaozz's profile 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 11 years ago.
remove samp from block elements
18807.samp-no-block-2.patch (2.0 KB) - added by toscho 11 years ago.
remove samp from block list in js and php
18807.samp-fix-3.patch (2.9 KB) - added by toscho 11 years ago.
3rd attempt to fix samp

Download all attachments as: .zip

Change History (21)

#1 @nacin
12 years ago

  • Keywords needs-patch added

#2 @jsumners
12 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.

#3 @nacin
12 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.

#4 @azaozz
12 years ago

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

@toscho
11 years ago

remove samp from block elements

#5 @toscho
11 years 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.

#6 follow-ups: @SergeyBiryukov
11 years 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.

@toscho
11 years ago

remove samp from block list in js and php

#7 in reply to: ↑ 6 @toscho
11 years 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.

#8 in reply to: ↑ 6 ; follow-up: @azaozz
11 years 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?

#9 in reply to: ↑ 8 ; follow-up: @toscho
11 years 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.

#10 in reply to: ↑ 9 @jsumners
11 years 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.

#11 @SergeyBiryukov
11 years ago

  • Keywords commit added

#12 @nacin
11 years ago

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

#13 @SergeyBiryukov
11 years 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.

@toscho
11 years ago

3rd attempt to fix samp

#14 follow-up: @toscho
11 years 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.

#15 @azaozz
11 years 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

#16 in reply to: ↑ 14 @azaozz
11 years 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.

#17 @ocean90
11 years ago

#23375 was marked as a duplicate.

#18 @toscho
11 years ago

#23858 was marked as a duplicate.

Note: See TracTickets for help on using tickets.