Opened 4 years ago
Closed 3 years ago
#8644 closed defect (bug) (fixed)
wpautop breaks <fieldset> and <legend> markup
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 2.9 |
| Component: | Formatting | Version: | 2.7 |
| Severity: | normal | Keywords: | needs-patch |
| Cc: |
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)
Change History (14)
- 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
- 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>
- Keywords needs-patch added; has-patch removed
- Milestone 2.8 deleted
patch is broken, but easy enough to fix. js patch is needed also
- Milestone set to 2.8
- Milestone changed from 2.8 to Future Release
punting pending patch
- Milestone changed from Future Release to 2.9
- 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.
- Keywords needs-patch added; has-patch tested wpautop removed
patch is stale...
comment:11
azaozz — 4 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.
comment:12
azaozz — 3 years ago
- Resolution set to fixed
- Status changed from accepted to closed

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