WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 8 months ago

#37814 closed defect (bug) (wontfix)

wpautop losing closing </pre> tags if doubled

Reported by: andyimatest Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.6
Component: Formatting Keywords: reporter-feedback
Focuses: Cc:
PR Number:

Description

wpautop is excluding the second closing </pre> tag if there are two in a row, one containing other attributes.

Example:
<pre><pre class="brush: csharp; title: ; notranslate" title="">
test test test
</pre></pre>

comes out as:

<pre><pre class="brush: csharp; title: ; notranslate" title="">
test test test
</pre>

Detected using SyntaxHighlighter Evolved plugin, using [csharp] shortcode in Text editor, switching to Visual editor (where encapsulating <pre></pre> are automatically added around the short-code), then previewing page.

Change History (2)

#1 @desrosj
10 months ago

  • Keywords close reporter-feedback added

Hi @andyimatest,

Welcome to Trac! First, my apologies that it took so long to receive a response.

The first thing that sticks out to me in your example is that the HTML class names are invalid. The ; and : characters cannot be used in the class attribute.

I have tried to reproduce the issue you are describing, but I am not having any success. Using the Classic Editor, When I paste your example text in to the Text editor, switch to the Visual editor, and then switch back to Text, I see the following:

<pre class="brush: csharp; title: ; notranslate" title="">test test test
</pre>

The outer <pre> tag us eliminated.

When using the block editor, if I switch to Edit as HTML, paste the example, and switch back to Edit Visually, the result is the following:

<pre class="wp-block-preformatted"><pre class="brush: csharp; title: ; notranslate" title="">test test test
</pre></pre>

The outer <pre> tag is preserved with the matching closing tag, but a class is added.

Are you still able to reproduce the issue you described originally? I am going to mark this as a close candidate, but please do provide more details if you can.

#2 @pento
8 months ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

A <pre> within a <pre> tag is invalid HTML, so wpautop() doesn't attempt to support it.

I'd be happy to consider a patch for this that doesn't cause significantly increased complexity to wpautop() (if someone uploads such a patch, we can re-open this ticket), but otherwise, I'm going to close this ticket as something we're not able to support.

Note: See TracTickets for help on using tickets.