Make WordPress Core

Opened 12 years ago

Closed 9 years ago

#23280 closed defect (bug) (duplicate)

TinyMCE issue with table wrapped with shortcode

Reported by: wpweaver's profile wpweaver Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5
Component: Shortcodes Keywords:
Focuses: Cc:

Description (last modified by ocean90)

TinyMCE will generate unbalanced <p> tags when a table is included as the content of a wrapping style shortcode. In this example, assume a shortcode called [div] ... [/div] that simply brackets the content with a <div> ... </div>.

This is an example as it would be in the editor's Text view (and it works if you switch back and forth to Visual.):


There will be a table following.

[div]
<table>
<tbody>
<tr>
<td>Simple table</td>
</tr>
</tbody>
</table>
[/div]

Next line is here.

The HTML output generated is this:

<p>There will be a table following.</p>
<div></p>
<table>
<tbody>
<tr>
<td>Simple table</td>
</tr>
</tbody>
</table>
<p></div>
<p>Next line is here.</p>

The shortcode is very simple - just a demo. It returns simply:

add_shortcode( 'div', function( $atts, $content ) {
	return '<div>' . do_shortcode( $content ) . '</div>';
} );

Doesn't seem to matter with or without the do_shortcode() call.


So note the excess </p> after the added starting <div>, and the extra <p> before the </div> from the shortcode. Seems to happen only with a wrapping style shortcode, and I think only with tables.

Change History (5)

#1 @wpweaver
12 years ago

  • Cc weaver@… added
  • Component changed from Editor to TinyMCE

#2 @SergeyBiryukov
12 years ago

  • Description modified (diff)

#3 @ocean90
11 years ago

  • Description modified (diff)

#4 @ocean90
11 years ago

  • Component changed from TinyMCE to Shortcodes

Thanks for the report wpweaver.

I could reproduce the issue in current trunk, also with a much simpler example.

[div]
<div>fooo</div>
[/div]

It seems like this happens to all block elements and if there is a space/break between the shortcode and the content, which makes me think, that this ticket is a dup of #24085.

#5 @miqrogroove
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #24085.

Note: See TracTickets for help on using tickets.