[wp-trac] [WordPress Trac] #35514: Shortcodes escape from HTML tables

WordPress Trac noreply at wordpress.org
Mon Jan 18 16:25:19 UTC 2016


#35514: Shortcodes escape from HTML tables
-------------------------------+------------------------------
 Reporter:  Grzegorz.Janoszka  |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  TinyMCE            |     Version:
 Severity:  normal             |  Resolution:
 Keywords:  2nd-opinion        |     Focuses:
-------------------------------+------------------------------
Changes (by ocean90):

 * keywords:  html table shortcode => 2nd-opinion
 * version:  4.4.1 =>


Old description:

> I have WP 4.4.1 and I am trying to use shortcodes with different
> arguments to create repetitive content, like rows in HTML tables. The
> problem is the editor removes the block from between <table> and </table>
> if it is not within <td> or <th> tags.
>
> Example, I have a shortcode that displays a nice HTML output containing a
> table row starting with <tr> and ending with </tr>.
>
> I open a new post, go to the text editor and type:
> <table>
> <tbody>
> [tablerow param1=blah param2=blah]
> </tbody>
> </table>
>
> Then I switch to the visual editor and back to text editor and I see:
> <table>
> <tbody></tbody>
> </table>
>
> When I try to add some more content to the table, like:
> <table>
> <tbody>
> <tr><td>Initial data</td></tr>
> [tablerow param1=blah param2=blah]
> </tbody>
> </table>
>
> it is being changed to:
> [tablerow param1=blah param2=blah]
> <table>
> <tbody>
> <tr>
> <td>Initial data</td>
> </tr>
> </tbody>
> </table>
>
> There is workaround to avoid putting <table> in the editor, but you have
> to use more shortcodes and no HTML code:
> [shortcode with table header]
> [shortcode with table row]
> [shortcode with table row]
> [shortcode with table row]
> [shortcode with table row]
> [shortcode with table footer]
>
> but it is not very handy.
>
> Is it possible that shortcodes are not moved out or removed from within
> <table> tags? They may simplify a lot creating repetitive content,
> including tables in Wordpress, but now it is difficult to achieve it with
> shortcodes.
>
> I think it is related to TinyMCE, so I have assigned this ticket to this
> component. Please feel free to reassign it.
>
> Thank you in advance for looking into it.

New description:

 I have WP 4.4.1 and I am trying to use shortcodes with different arguments
 to create repetitive content, like rows in HTML tables. The problem is the
 editor removes the block from between <table> and </table> if it is not
 within <td> or <th> tags.

 Example, I have a shortcode that displays a nice HTML output containing a
 table row starting with <tr> and ending with </tr>.

 I open a new post, go to the text editor and type:

 {{{
 <table>
 <tbody>
 [tablerow param1=blah param2=blah]
 </tbody>
 </table>
 }}}


 Then I switch to the visual editor and back to text editor and I see:

 {{{
 <table>
 <tbody></tbody>
 </table>
 }}}


 When I try to add some more content to the table, like:

 {{{
 <table>
 <tbody>
 <tr><td>Initial data</td></tr>
 [tablerow param1=blah param2=blah]
 </tbody>
 </table>
 }}}


 it is being changed to:

 {{{
 [tablerow param1=blah param2=blah]
 <table>
 <tbody>
 <tr>
 <td>Initial data</td>
 </tr>
 </tbody>
 </table>
 }}}


 There is workaround to avoid putting <table> in the editor, but you have
 to use more shortcodes and no HTML code:

 {{{
 [shortcode with table header]
 [shortcode with table row]
 [shortcode with table row]
 [shortcode with table row]
 [shortcode with table row]
 [shortcode with table footer]
 }}}

 but it is not very handy.

 Is it possible that shortcodes are not moved out or removed from within
 <table> tags? They may simplify a lot creating repetitive content,
 including tables in Wordpress, but now it is difficult to achieve it with
 shortcodes.

 I think it is related to TinyMCE, so I have assigned this ticket to this
 component. Please feel free to reassign it.

 Thank you in advance for looking into it.

--

Comment:

 Hello @Grzegorz.Janoszka, welcome to Trac!

 Thanks for your report, I could reproduce the issue on the demo site at
 https://www.tinymce.com/docs/demo/basic-example/ and also in other
 versions of WordPress. I'm not sure if core or TinyMCE can do something to
 prevent this behaviour since the HTML markup isn't valid.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35514#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list