Skip to content

HTML Block adding random close tags and line breaks on template pages #50173

Closed

Description

@dalebridge

Description

HTML Block adding in random </p> and <br /> tags throughout the HTML block. I notice it most in ones where I have an SVG within the HTML block as it breaks the SVG and it sometimes stops displaying. The HTML block keeps trying to close P tags that were never present, and adding in line breaks to SVGs completely breaking them.

Step-by-step reproduction instructions

Create a custom product template.

Add in a HTML block.

Add code, including an SVG.

View page.

Return to template

See added </p> and <br /> tags throughout code that were not present before.

Screenshots, screen recording, code snippet

https://www.loom.com/share/30b07eddd73348baa557df9c8765c785
code.txt

Environment info

Wordpress 6.2
Woocommerce 7.6.1

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Activity

  1. kathrynwp commented on May 1, 2023

    @kathrynwp

    Hey there @dalebridge - thanks for the report.

    In order for me to try to replicate the issue, could you please provide a short piece of sample code that I can try in an HTML block? Thanks!

  2. added
    [Block] HTML
    [Type] Bug
    [Status] Needs More Info
    on May 1, 2023
  3. dalebridge commented on May 1, 2023

    @dalebridge
    Author

    hi @kathrynwp , the code is added above in code.txt.

    If you need anything else let me know!

  4. kathrynwp commented on May 1, 2023

    @kathrynwp

    Thanks, @dalebridge ! For security reasons I'm not going to be able to open the attachment, so thanks for reading my mind and copy-pasting the code above. :)

  5. kathrynwp commented on May 1, 2023

    @kathrynwp

    @dalebridge I haven't been able to replicate the problem so far when creating a custom page template – I'm not seeing any stray tags added to the code you provided, in an HTML block.

    Create a custom product template.

    Are you finding that this issue only happens with Woo product templates specifically, or can you get it happen with core templates as well?

  6. dalebridge commented on May 1, 2023

    @dalebridge
    Author

    It only happens in templates, not posts

  7. dalebridge commented on May 1, 2023

    @dalebridge
    Author

    @kathrynwp it only happens on block templates

  8. kathrynwp commented on May 1, 2023

    @kathrynwp

    @dalebridge Yep, I understand that. :) In your testing instructions you said "Create a custom product template."

    WooCommerce and product templates like the "Single Item: Product" example in your video are not part of WordPress core. So I was wondering if if you've been able to replicate this with any of the templates that are part of core, as you see here:

    Home_‹_Template_‹_Editor_‹_Test_Site_ABC_—_WordPress

    I tried adding a Custom HTML block with the sample code you provided earlier (seems like it's been deleted now?) but was not able to replicate the issue with stray tags appearing, so far:

    <div> <svg width="2039px" height="77px" viewBox="0 0 2039 77" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="margin-top: -9px"> <title>Rectangle</title> <g id="PowerGlide-V2" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <path d="M0,0 L2039,0 L2039,8.67957425 C1581.67037,5.21398885 1241.83704,27.9874641 1019.5,77 C796.507314,28.2268289 456.67398,5.45335361 0,8.67957425 L0,0 Z" id="Rectangle" fill="#2E3548"></path> </g> </svg> </div>
    
    
  9. dalebridge commented on May 1, 2023

    @dalebridge
    Author

    I deleted that code as it formatted it inline after pasting into a code-block here, rather than how I had been using it, so I wanted to give you an accurate version of the code via gist. https://gist.github.com/dalebridge/df5b4da8192f3152bc110df2cf6ff1aa

    https://www.loom.com/share/30b07eddd73348baa557df9c8765c785

    I used a "single item: product", but it did the same on home template too @kathrynwp

  10. dalebridge commented on May 1, 2023

    @dalebridge
    Author

    @kathrynwp and on home template with a fresh install – https://www.loom.com/share/17d0914ced7d4b40a197b43f318fdc3e

    Rocking in this environment:
    wordpress 6.2
    woocommerce 7.6.0

  11. dalebridge commented on May 2, 2023

    @dalebridge
    Author

    @kathrynwp

    New environment again, no WooCommerce installed, just 6.2.

    Editing Home template, no changes to the page other than the added HTML block to paste my HTML into.

    Pasted in code into the HTML block (this one doesn't include an SVG, purely divs and a tags.)

    After saving, leaving the page and coming back, it adds in a load of <p> </p> tags throughout the code, ruining the flex box css I had applied to the classes. Code for this is below, along with a video demonstration.

    https://www.loom.com/share/732c736601354b7984c11e076e60dbc7

    https://gist.github.com/dalebridge/81540ef6df25ec3666f1e0f2dff8da4d

  12. connah99 commented on May 2, 2023

    @connah99

    There's another issue regarding the same topic. Some testing and examples are in there too, in case that's of any help

    Related: Custom HTML block adding extra characters #49166

  13. github-actions commented on May 18, 2023

    @github-actions

    Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks.

  14. added
    [Status] Stale
    on May 18, 2023
  15. dalebridge commented on May 18, 2023

    @dalebridge
    Author

    There has been more information added. It is all above. Code. How to replicate. Videos of the issue in action.

  16. removed
    [Status] Needs More Info
    [Status] Stale
    on May 18, 2023
  17. jordesign commented on Aug 8, 2023

    @jordesign
    Contributor

    It appears this should be resolved with the update to WordPress 6.3
    #49166

    @dalebridge can you please let me know if you still see this issue in place after updating to the latest version of WordPress?

  18. homebrandcola commented on Aug 30, 2024

    @homebrandcola

    Just ran into this issue in 6.6.1 running theme twenty twenty-two

    I have some custom script and an input box on a page and when I add it, it gets populated with

    and
    tags throughout the script and breaks it all.

    I see the issue is still open, but was supposed to fixed in 6.3?

  19. carolinan commented on Mar 18, 2026

    @carolinan
    Contributor

    I am not able to reproduce this:

    • Using the sample code from the gist
    • I used the HTML panel of the HTML block.
    • WordPress 7.0 beta 5
      (Gutenberg is not active)
  20. added
    Needs Design
    on Mar 18, 2026
  21. jasmussen commented on Aug 26, 2026

    @jasmussen
    Contributor

    This appears resolved. The root cause, autop() running on raw block content when the freeform fallback block was core/html in the site editor/templates, should be fixed by #52716, which shipped in WordPress 6.3. That fix is still present in trunk (packages/blocks/src/api/parser/index.ts, gating autop to core/freeform only).Closing as fixed. If anyone can still reproduce this on a current release with a minimal repro, please reopen with the steps and environment details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs Design[Block] HTML[Type] Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions