Skip to content

Try: edit any HTML as blocks (with HTML tag processor port) - #85500

Draft
ellatrix wants to merge 9 commits into
trunkfrom
try/experiment-b780f0
Draft

ellatrix wants to merge 9 commits into
trunkfrom
try/experiment-b780f0

Conversation

@ellatrix

@ellatrix ellatrix commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

What?

HTML without block delimiters, like a classic post, opens as blocks instead of one Classic block. Blocks that aren't edited are saved as they were read, and blocks read without delimiters stay without them unless an edit needs one. New blocks get delimiters as before.

Why?

So Gutenberg can edit any HTML, like a classic post, without converting it or adding block markup.

How?

  • Adds @wordpress/html-api, a JS port of the WordPress HTML Tag Processor.
  • HTML outside delimiters is read as blocks instead of one Classic block. Elements no block reads become HTML blocks, with the blocks inside them editable.
  • Untouched blocks are saved exactly as written. Edited blocks change only what the edit changed, and get a delimiter only when reading the HTML back without one would give a different block.
  • Attributes a block doesn't know are kept in htmlAttributes, shown in the editor and saved again.

Testing Instructions

  1. Create a post with HTML without delimiters, for example with WP-CLI: wp post create --post_title=Test --post_content='<p style="background:#fffbe6">Hello</p><section class="x"><h3>Title</h3><p>Text</p></section>'.
  2. Open it in the editor. The paragraph is a Paragraph block with its background, and the section is a Custom HTML block with an editable heading and paragraph.
  3. Edit the inner paragraph's text and save. Check that only that text changed, and that no delimiters were added.

Testing Instructions for Keyboard

Same as above, typing the edit with the keyboard.

Use of AI Tools

Written with Claude Code (Claude Opus 5.5), reviewed by me.

🤖 Generated with Claude Code

ellatrix and others added 2 commits October 23, 2026 18:48
Behind the "Optional block delimiters" experiment, HTML without block
delimiters opens as blocks and is saved without them where possible.

- Add @wordpress/html-api, a port of the WordPress HTML Tag Processor.
- Read HTML outside delimiters as blocks instead of one Classic block.
  Elements no block reads become HTML blocks, with the blocks inside
  them editable.
- Save untouched blocks exactly as written. Edited blocks change only
  what the edit changed, and get a delimiter only when reading the HTML
  back without one would give a different block.
- Keep attributes a block doesn't know in `htmlAttributes`, show them
  in the editor and save them again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added [Package] Blocks /packages/blocks [Package] Block editor /packages/block-editor labels Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

📦 Bundle size

Size Change: +24.8 kB (+0.27%)

Total Size: 9.09 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 607 kB +393 B (+0.06%)
build/scripts/blocks/index.min.js 70.9 kB +24.4 kB (+52.57%) 🆘

48db6c9 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric a93c036 trunk % Change
timeToFirstByte 48.3 ms +18.74% -1.76% 47.65 ms +6.82% -2.94% 1.36%
largestContentfulPaint 86 ms +9.3% -6.98% 82 ms +7.32% -2.44% 4.88%
lcpMinusTtfb 34.7 ms +13.26% -7.35% 33.85 ms +18.61% -4.14% 2.51%
wpBeforeTemplate 24.85 ms +17.46% -2.62% 24.09 ms +6.23% -2.32% 3.15%
wpTemplate 19.74 ms +5.78% -2.63% 19.68 ms +3.61% -4.67% 0.3%
wpTotal 44.56 ms +17.82% -1.93% 43.82 ms +7.05% -2.72% 1.69%
wpMemoryUsage 7.68 MB +0% -0% 7.65 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric a93c036 trunk % Change
timeToFirstByte 40.3 ms +2.23% -2.36% 35.65 ms +3.37% -0.56% 13.04%
largestContentfulPaint 94 ms +2.13% -2.13% 80 ms +5% -0% 17.5%
lcpMinusTtfb 53.35 ms +4.31% -3.37% 44.8 ms +5.25% -0.89% 19.08%
wpBeforeTemplate 21.69 ms +3.14% -2.95% 21.59 ms +3.8% -1.71% 0.46%
wpTemplate 15.15 ms +5.48% -2.9% 11.41 ms +1.14% -2.37% 32.78%
wpTotal 37.22 ms +1.91% -2.96% 32.81 ms +3.41% -0.88% 13.44%
wpMemoryUsage 6.37 MB +0% -0% 6.22 MB +0% -0% 2.33%
wpDbQueries 13 +0% -0% 9 +0% -0% 44.44%

media-processing

Metric a93c036 trunk % Change
mediaProcessingJpeg 401.88 ms +0.64% -0.36% 395.62 ms +0.84% -0.12% 1.58%
mediaProcessingAvif 5826.52 ms +0.21% -0.08% 5815.36 ms +0.09% -0.11% 0.19%
mediaProcessingJpegToAvif 3984.56 ms +0.02% -0.39% 3975.99 ms +0.21% -0.14% 0.22%

media-upload

Metric a93c036 trunk % Change
jpegUploadProcessing 1699.07 ms +14.86% -15.39% 1434.64 ms +0.83% -0.5% 18.43%
pngUploadProcessing 200.76 ms +4.74% -2.79% 214.4 ms +1.07% -6.32% -6.36%
largeJpegUploadProcessing 1436.89 ms +1.08% -0.66% 1438.01 ms +0.7% -0.4% -0.08%
multipleImageUploadProcessing 2016.23 ms +0.9% -22.26% 2033.62 ms +1.4% -22.38% -0.86%

post-editor

Metric a93c036 trunk % Change
serverResponse 521.65 ms +4.18% -1.93% 528.97 ms +2.43% -4.71% -1.38%
firstPaint 372.51 ms +45.18% -31.15% 352 ms +57.08% -13.55% 5.83%
domContentLoaded 1289.9 ms +0.26% -3.22% 1282.93 ms +2.08% -1.78% 0.54%
loaded 1291.39 ms +0.27% -3.21% 1284.35 ms +2.07% -1.8% 0.55%
firstContentfulPaint 552 ms +7.56% -3.5% 557.77 ms +1.66% -17.42% -1.03%
firstBlock 3661.85 ms +5.25% -1.07% 3661.84 ms +4.88% -0.67% 0%
type 20.94 ms +1.29% -6.02% 20.35 ms +3.64% -8.55% 2.9%
typeWithoutInspector 19.63 ms +4.48% -3.46% 18.96 ms +11.97% -2.32% 3.53%
typeWithTopToolbar 26.66 ms +2.44% -9.34% 26.83 ms +4.21% -7.57% -0.63%
typeContainer 9.52 ms +9.98% -11.34% 8.76 ms +7.65% -2.63% 8.68%
focus 134.52 ms +11.8% -6.42% 130.57 ms +7.15% -3.02% 3.03%
firstFocus 272.7 ms +0% -0% 246.24 ms +0% -0% 10.75%
selectAll 620.52 ms +0.14% -3.14% 596.49 ms +6.6% -0.69% 4.03%
listViewOpen 88.79 ms +4.79% -7.53% 99.58 ms +3.91% -11.05% -10.84%
inserterOpen 49.07 ms +9.07% -5.38% 52.59 ms +5.8% -2.7% -6.69%
inserterHover 12.76 ms +9.48% -7.68% 14.38 ms +3.89% -7.58% -11.27%
inserterSearch 10.08 ms +3.67% -8.13% 9.65 ms +7.77% -11.3% 4.46%
loadPatterns 701.91 ms +5.94% -3.78% 720 ms +1.81% -5.13% -2.51%
wpTotal 511.28 ms +4.48% -1.86% 519.24 ms +2.34% -4.85% -1.53%
wpMemoryUsage 14.71 MB +0% -0% 14.68 MB +0% -0% 0.24%
wpDbQueries 55 +0% -1.82% 54.5 +0.92% -0.92% 0.92%

site-editor

Metric a93c036 trunk % Change
serverResponse 301.96 ms +3.76% -6.95% 320.1 ms +1.42% -4.65% -5.67%
firstPaint 228.52 ms +17.29% -20.6% 198.55 ms +7.7% -11.5% 15.09%
domContentLoaded 980.97 ms +1.51% -3.27% 961.2 ms +0.63% -0.42% 2.06%
loaded 982.03 ms +1.52% -3.29% 962.01 ms +0.65% -0.41% 2.08%
firstContentfulPaint 400.12 ms +2.94% -17.67% 395.78 ms +4.87% -4.35% 1.1%
firstBlock 3427.79 ms +2.46% -1.2% 3395.27 ms +1.73% -0.26% 0.96%
type 15.64 ms +3.32% -1.92% 16.46 ms +0.67% -5.29% -4.98%
navigate 89.57 ms +4.81% -8.95% 98.84 ms +2.91% -9.64% -9.38%
loadPatterns 1074.07 ms +6.9% -7.71% 1062.73 ms +13.45% -1.19% 1.07%
loadPages 1037.64 ms +3.49% -2.34% 1037.3 ms +2.06% -3.36% 0.03%
wpTotal 294.13 ms +3.76% -7.23% 312.03 ms +1.46% -4.76% -5.74%
wpMemoryUsage 12.74 MB +0% -0% 12.70 MB +0% -0% 0.28%
wpDbQueries 44 +2.27% -0% 44 +2.27% -0% 0%

48db6c9 Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

Custom Completer: should allow newlines after multiple option completions in /test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 3
+ Received  + 3

  <!-- wp:paragraph -->
  <p>🫐 test</p>
  <!-- /wp:paragraph -->

  <!-- wp:paragraph -->
- <p>🫐 test</p>
+ <p>🍎 test</p>
  <!-- /wp:paragraph -->

  <!-- wp:paragraph -->
- <p>🫐 test</p>
+ <p>~🍎 test</p>
  <!-- /wp:paragraph -->

  <!-- wp:paragraph -->
- <p>🫐 test</p>
+ <p>🍎 test</p>
  <!-- /wp:paragraph -->

  <!-- wp:paragraph -->
  <p></p>
  <!-- /wp:paragraph -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js:466:6
Navigates the items list via UP/DOWN arrow keys in /test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  getByLabel('Page Two')
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" getByLabel('Page Two') with timeout 5000ms
  - waiting for getByLabel('Page Two')
    14 × locator resolved to <button type="button" tabindex="-1" aria-pressed="false" id="view-list-0-178-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-178-label" aria-describedby="view-list-0-178-description"></button>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:146:49
Undo restores the post selection when another synced entity is loaded (RTC WebSocket) in /test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

  Object {
    "attributeKey": "content",
    "blockIndex": 0,
    "content": "abcdef",
-   "endOffset": 3,
-   "offset": 3,
+   "endOffset": 1,
+   "offset": 1,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts:363:5
should change the indented list type in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('role=toolbar[name="Block tools"i]').locator('role=button[name="Indent"]')

    at Editor.clickBlockToolbarButton (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/click-block-toolbar-button.ts:17:15)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:727:3
should indent and outdent level 2 in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('role=toolbar[name="Block tools"i]').locator('role=button[name="Indent"]')

    at Editor.clickBlockToolbarButton (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/click-block-toolbar-button.ts:17:15)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:933:3
should keep a selection ending after a non-breaking space in /test/e2e/specs/editor/various/multi-block-selection.spec.js, passed after 1 failed attempt.
Error: expect(received).toEqual(expected) // deep equality

- Expected  - 2
+ Received  + 2

  Object {
-   "anchorOffset": 3,
+   "anchorOffset": 2,
    "blocks": 2,
-   "focusOffset": 2,
+   "focusOffset": 1,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/multi-block-selection.spec.js:2326:37
should merge a following sibling list into the outermost list with Delete from a nested item (#77245) in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

@@ -8,11 +8,11 @@
          "innerBlocks": Array [
            Object {
              "innerBlocks": Array [
                Object {
                  "attributes": Object {
-                   "content": "b‸",
+                   "content": "b",
                  },
                  "name": "core/list-item",
                },
              ],
              "name": "core/list",
@@ -25,11 +25,11 @@
    },
    Object {
      "innerBlocks": Array [
        Object {
          "attributes": Object {
-           "content": "1",
+           "content": "‸1",
          },
          "innerBlocks": Array [
            Object {
              "innerBlocks": Array [
                Object {

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:2854:41
should outdent with children in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('role=toolbar[name="Block tools"i]').locator('role=button[name="Indent"]')
    - locator resolved to <button id="_r_1l_" type="button" tabindex="-1" aria-label="Indent" aria-disabled="true" data-toolbar-item="true" data-truly-disabled="false" aria-describedby="components-button__description-26" class="components-button components-toolbar-button is-compact has-icon">…</button>
  - attempting click action
    2 × waiting for element to be visible, enabled and stable
      - element is not enabled
    - retrying click action
    - waiting 20ms
    2 × waiting for element to be visible, enabled and stable
      - element is not enabled
    - retrying click action
      - waiting 100ms
    18 × waiting for element to be visible, enabled and stable
       - element is not enabled
     - retrying click action
       - waiting 500ms

    at Editor.clickBlockToolbarButton (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/click-block-toolbar-button.ts:17:15)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:1055:3
should replace the selection across blocks with an inline image in /test/e2e/specs/editor/various/multi-block-selection.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 6
+ Received  + 2

  Array [
    Object {
      "attributes": Object {
        "content": "ab",
+       "dropCap": false,
      },
-     "name": "core/paragraph",
-   },
-   Object {
-     "attributes": Object {
-       "content": "ab",
-     },
+     "innerBlocks": Array [],
      "name": "core/paragraph",
    },
  ]

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/multi-block-selection.spec.js:2372:41
should update the URL from the last navigation if only varies in the URL fragment in /test/e2e/specs/interactivity/router-navigate.spec.ts, passed after 1 failed attempt.
Error: expect(locator).toHaveText(expected) failed

Locator:  getByTestId('title')
Expected: "Link 1"
Received: "Main"
Timeout:  5000ms

Call log:
  - Expect "toHaveText" getByTestId('title') with timeout 5000ms
  - waiting for getByTestId('title')
    14 × locator resolved to <h2 data-testid="title">Main</h2>
       - unexpected value "Main"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/interactivity/router-navigate.spec.ts:160:25
shows title and sync status while creating a new synced pattern in the post editor in /test/e2e/specs/editor/various/post-summary/post-summary.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeVisible() failed

Locator: getByRole('dialog', { name: 'Create pattern' })
Expected: visible
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeVisible" getByRole('dialog', { name: 'Create pattern' }) with timeout 5000ms
  - waiting for getByRole('dialog', { name: 'Create pattern' })

    at createPatternFromModal (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/post-summary/post-summary.spec.js:179:26)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/post-summary/post-summary.spec.js:101:4

48db6c9 Run

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ellatrix and others added 6 commits October 25, 2026 08:27
Inner blocks of a block like List were each read back on their own to
decide whether they need a delimiter. A list item alone isn't a list
item, so editing one saved the whole list with delimiters. Inner blocks
are now read back as part of their parent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the experiment: HTML outside delimiters is always read as blocks,
and blocks that weren't edited are always saved as they were read. New
blocks get delimiters as before.

- Without a DOM or the HTML block, HTML is read and saved as before.
- The current version of a block reads its HTML first, keeping unknown
  attributes in `htmlAttributes`; older versions are tried after.
- Invalid blocks are saved as they were read, and logged as before.
- Pasting HTML outside delimiters goes through raw handling again.
- The full content fixtures check what blocks save, with the source set
  aside; untouched content is checked by the delimiter tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only HTML without delimiters is read for blocks inside it. A delimited
Custom HTML block keeps its static HTML, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A delimited block inside HTML without delimiters, like a paragraph in a
section, used to cut the HTML apart when read, so saving one wrapped the
whole HTML in a Custom HTML block. HTML outside delimiters is now read in
one pass with the delimited blocks in it, which become inner blocks of
an HTML block where they sit inside an element.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Post content is rendered with a parser that reads HTML outside block
delimiters as blocks, the same way the editor does, so render filters
see each block.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ellatrix ellatrix changed the title Try: Experiment Try: edit any HTML (with HTML tag processor port) Nov 9, 2026
@ellatrix ellatrix changed the title Try: edit any HTML (with HTML tag processor port) Try: edit any HTML as blocks (with HTML tag processor port) Nov 9, 2026

This branch has not been deployed

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

Labels

[Package] Block editor /packages/block-editor [Package] Blocks /packages/blocks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant