WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 3 months ago

#14674 reopened defect (bug)

HR destroys HTML

Reported by: thomask Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0
Component: Formatting Keywords: has-patch needs-testing wpautop
Focuses: Cc:

Description

if you add <hr /> to the post (via HTML editor, or via enhanced TinyMCE editor) followed by normal text id do not add the <p> for that paragraph, but add the finishing </p>

so it than looks like

<p>some text</p>
<hr>some other text</p>

it can be solved by adding extra line break after <hr> but after reediting the post, the linebreak disapears and must be added again.

Attachments (2)

14674.diff (1.4 KB) - added by solarissmoke 5 years ago.
HR's are a special case of block level element because they self-close
14674.2.diff (960 bytes) - added by solarissmoke 3 years ago.
Refreshed

Download all attachments as: .zip

Change History (15)

comment:1 @dd325 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

@solarissmoke5 years ago

HR's are a special case of block level element because they self-close

comment:2 @solarissmoke5 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

I think the problem was the wpautop was expecting to find a closing tag for the hr element, like it does with all other block-level elements. This patch fixes it for me but needs testing to be sure it doesn't break anything else.

comment:3 @WraithKenny3 years ago

  • Keywords wpautop added

comment:4 @MikeHansenMe3 years ago

  • Keywords needs-refresh needs-patch added; has-patch needs-testing removed

@solarissmoke3 years ago

Refreshed

comment:5 @solarissmoke3 years ago

  • Keywords has-patch added; needs-refresh needs-patch removed

comment:6 @MikeHansenMe3 years ago

  • Keywords close added

not sure why I asked for refresh. This problem seems to be fixed in the current version 3.5-alpha-21751. Proposing we close the ticket.

comment:7 follow-up: @SergeyBiryukov3 years ago

  • Keywords close removed

I can still reproduce in trunk.

  1. Copy this into Text editor:
    <p>some text</p> <hr />some other text
    
  2. Preview the post.
  3. View HTML source of the page:
    <p>some text</p>
    <hr />some other text</p>
    

comment:8 in reply to: ↑ 7 @chriscct73 months ago

  • Keywords wpautop has-patch removed
  • Milestone Future Release deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Replying to SergeyBiryukov:

I can still reproduce in trunk.

  1. Copy this into Text editor:
    <p>some text</p> <hr />some other text
    
  2. Preview the post.
  3. View HTML source of the page:
    <p>some text</p>
    <hr />some other text</p>
    

This now works on 4.2. Closing as works for me.

comment:9 @SergeyBiryukov3 months ago

  • Keywords wpautop has-patch added
  • Milestone set to Future Release
  • Resolution worksforme deleted
  • Status changed from closed to reopened

I can still reproduce comment:7 in 4.2 exactly as described.

comment:10 @chriscct73 months ago

This is wierd. I think I know why me and @MikeHansonMe can't replicate this.

Depending on the browser used, the browsers try to fix the error I think.

This is what I get in Chrome:

<p>some text</p>
<hr>some other text<p></p>

but this is what I get in FireFox:

<p>some text</p>
<hr></hr>some other text<p></p>

What browser are you using?

comment:11 follow-up: @SergeyBiryukov3 months ago

Firefox 37.0.2.

Make sure to actually view the page source, not via Inspect Element. I think both Firebug and Chrome Developer Tools try to normalize invalid HTML.

comment:12 in reply to: ↑ 11 @chriscct73 months ago

  • Keywords needs-testing added; wpautop removed
  • Version changed from 3.0.1 to 3.0

Replying to SergeyBiryukov:

Firefox 37.0.2.

Make sure to actually view the page source, not via Inspect Element. I think both Firebug and Chrome Developer Tools try to normalize invalid HTML.

Ah I see now. Yep, that needs to be fixed.

Tagging patch as needs testing.

comment:13 @chriscct73 months ago

  • Keywords wpautop added
Note: See TracTickets for help on using tickets.