WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#8644 closed defect (bug) (fixed)

wpautop breaks <fieldset> and <legend> markup

Reported by: MarkBlankestijn Owned by: Sam_a
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.7
Component: Formatting Keywords: needs-patch
Focuses: Cc:
PR Number:

Description

I use the fieldset (and legend) tag in my posts. These tags aren't parsed correctly by Wordpress and produces invalid XHTML. I'm not sure if it's correct, but this is how I fixed it:

formatting.php

Line 120; add fieldset and legend:

$allblocks = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|map|area|blockquote|fieldset|legend|address|math|style|input|p|h[1-6]|hr)';

Add the following line, e.g. below line 139:

$pee = str_replace('</fieldset>', '</p></fieldset>', $pee);

Attachments (2)

8644_wpautop_fieldset_legend.diff (566 bytes) - added by Sam_a 11 years ago.
Adds FIELDSET and LEGEND to wpautop's list of HTML block elements
autop_fieldset_legend.diff (1.7 KB) - added by Sam_a 10 years ago.
Stops autop from breaking fieldset & legend markup

Download all attachments as: .zip

Change History (14)

@Sam_a
11 years ago

Adds FIELDSET and LEGEND to wpautop's list of HTML block elements

#1 @Sam_a
11 years ago

  • Keywords has-patch wpautop added
  • Owner changed from anonymous to Sam_a
  • Status changed from new to assigned
  • Summary changed from Include <fieldset> and <legend> in formatting.php to wpautop should recognize <fieldset> and <legend> as block elements
  • Type changed from enhancement to defect (bug)
  • Version set to 2.7

#2 @Sam_a
11 years ago

  • Summary changed from wpautop should recognize <fieldset> and <legend> as block elements to wpautop breaks <fieldset> and <legend> markup

Patch stops wpautop from wrapping fieldset and legend in paragraph tags.

But I still see invalid markup when text inside the fieldset has less than 2 newlines above and below it; wpautop inserts <p> but omits </p>:

<?php echo wpautop("<fieldset><legend>Legend</legend>Text inside fieldset</fieldset>"); ?>
<fieldset>
<legend>Legend</legend>
<p>Text inside fieldset</fieldset>

#3 @Sam_a
11 years ago

  • Owner Sam_a deleted
  • Status changed from assigned to new

#4 @ryan
11 years ago

  • Component changed from General to Formatting

#5 @Denis-de-Bernardy
11 years ago

  • Keywords needs-patch added; has-patch removed
  • Milestone 2.8 deleted

patch is broken, but easy enough to fix. js patch is needed also

#6 @Denis-de-Bernardy
11 years ago

  • Milestone set to 2.8

#7 @Denis-de-Bernardy
11 years ago

  • Milestone changed from 2.8 to Future Release

punting pending patch

#8 @Denis-de-Bernardy
11 years ago

  • Milestone changed from Future Release to 2.9

@Sam_a
10 years ago

Stops autop from breaking fieldset & legend markup

#9 @Sam_a
10 years ago

  • Keywords has-patch tested added; needs-patch removed
  • Owner set to Sam_a
  • Status changed from new to accepted

Attached patch autop_fieldset_legend.diff seems to fix the problem in trunk.

#10 @Denis-de-Bernardy
10 years ago

  • Keywords needs-patch added; has-patch tested wpautop removed

patch is stale...

#11 @azaozz
10 years ago

The problem is larger that this. It may affect any block element that can contain other block elements like <div>, <td>, <th>, <fieldset>, <dd>, etc. Been working on a patch to fix all or nearly all of these cases but it still needs a lot of testing.

#12 @azaozz
10 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [12275]) Autop: add fieldset to blocks, remove support for empty <p> for now, fix block in block problems when switching the editor from visual to html and back, fixes #8644

Note: See TracTickets for help on using tickets.