Make WordPress Core

Opened 17 years ago

Closed 6 weeks ago

#5250 closed defect (bug) (wontfix)

wpautop() issue with lists

Reported by: narc0tiq's profile Narc0tiq Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.3
Component: Formatting Keywords: needs-patch needs-unit-tests wpautop
Focuses: Cc:

Description (last modified by johnbillion)

First of all, my sincere apologies if this is a duplicate.

The problem, in short: WordPress inserted a number of unclosed <p> tags into my post. It should either insert correctly closed tags, or none at all. I honestly would prefer the former.

In detail: I had HTML code very similar to this:

<ul>
  <li>text<ul>
    <li>subtext</li>
  </ul>more text</li>
</ul>

This was automatically converted to:

<ul>
  <li>text<ul>
    <li>subtext</li>
  </ul><p>more text</li>
</ul>

Note the extra <p> tag in the above, which is unclosed (making the W3C validator choke on my website).

Also note, I was not using the WYSIWYG editor (turning it off was the first thing I did), so it's unlikely to be due to that.

As a workaround, manually inserting properly closed <p> tags works just fine:

<ul>
  <li>text<ul>
    <li>subtext</li>
  </ul><p>more text</p></li>
</ul>

Since this workaround exists, the bug is not very prioritary, but it should also (hopefully) be easy to fix.

Change History (17)

#1 @Narc0tiq
17 years ago

  • Milestone 2.5 deleted

#2 @Otto42
17 years ago

  • Keywords autop added
  • Milestone set to 2.4
  • Priority changed from low to normal
  • Severity changed from trivial to normal

#3 @Viper007Bond
17 years ago

Another work around is just to add in some line breaks:

<ul>
	<li>Some text!
		<ul>
			<li>More text!</li>
		</ul>
	</li>
</ul>

#4 @Viper007Bond
17 years ago

  • Keywords needs-patch added; xhtml autop removed
  • Summary changed from Unclosed p tags -- not XHTML-compliant! to wpautop() issue with nested lists

I take that back. I forgot the text after the first </ul> and even with more line breaks, it added in a <p>. My apologies.

#5 @foolswisdom
17 years ago

  • Keywords xhtml autop added

#6 @darkdragon
17 years ago

  • Component changed from General to Template

#7 @Denis-de-Bernardy
15 years ago

  • Component changed from Template to Formatting

#8 @azaozz
15 years ago

  • Milestone changed from 2.9 to Future Release

#9 @Jani Uusitalo
13 years ago

  • Summary changed from wpautop() issue with nested lists to wpautop() issue with lists

This looks related to a test case I was preparing to demonstrate how flawed the output from wpautop can get inside lists:

<ol>
<li>
foo

bar
</li>
</ol>

renders as:

<ol> 
<li> 
foo</p> 
<p>bar
</li> 
</ol>

whereas I'd expect it to be

<ol> 
<li> 
<p>foo</p> 
<p>bar</p>
</li> 
</ol>

I'm changing the summary to generally cover wpautop's problems within <li> elements.

#10 @Jani Uusitalo
13 years ago

  • Cc Jani Uusitalo added

#11 @nacin
11 years ago

  • Keywords wpautop added; autop removed

#12 @chriscct7
9 years ago

  • Keywords needs-unit-tests added; xhtml wpautop removed
  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Closing as wontfix. Complete lack of interest on the ticket over the last 4 years. Feel free to reopen when more interest re-emerges (particularly if there's a patch)

#13 @johnbillion
9 years ago

  • Description modified (diff)

#14 @miqrogroove
9 years ago

  • Keywords wpautop added
  • Milestone set to Future Release
  • Resolution wontfix deleted
  • Status changed from closed to reopened

#15 follow-up: @Mte90
18 months ago

  • Keywords close added

Tested with 6.2 alpha:

<ol>
<li>
foo

bar
</li>
</ol>

Generates:

<p><ol>
<li>
foo

bar
</li>
</ol></p>

I think that is right and fine as behavior.

#16 in reply to: ↑ 15 @lev0
6 weeks ago

Replying to Mte90:

<p><ol>
<li>
foo

bar
</li>
</ol></p>

I think that is right and fine as behavior.

It looks like that case has always been actively prevented, to me.

#17 @Otto42
6 weeks ago

  • Keywords close removed
  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from reopened to closed

Closing once again due to lack of interest over the last 17 years. Also, wpautop is kind of not used with the block editor anymore. Please don't reopen this without a patch.

Note: See TracTickets for help on using tickets.