Repository navigation
Conversation
convertHtmlToBlocks() emitted <!-- wp:heading {"level":N} --> for h1 and
h3-h6, but a bare <!-- wp:heading --> for h2. Bare-for-h2 matches
Gutenberg's own canonical serialization (default attributes are
omitted), but a converter with one implicit case among six explicit ones
produces inconsistent output across heading levels — and when existing
content whose blocks carried an explicit {"level":2} was round-tripped
through convert_to_blocks, the attribute vanished, which was reported
from the field as "the level got stripped off every heading block".
All six heading tags now share one case that emits the level explicitly;
an explicit default attribute is valid for the block parser. Content
already in block format is untouched (pass-through happens before the
converter), covered by a test.
Tests drive create_content with convert_to_blocks through the mocked
transport and inspect the written content: 3/4 fail against the previous
implementation.
Co-Authored-By: Claude <noreply@anthropic.com>
Review nit: the bare '{"level":2}' substring could pass via some other
block type; use the file's stronger exact-comment idiom.
Co-Authored-By: Claude <noreply@anthropic.com>
|
Kilo Code Review could not run — your account is out of credits. Add credits or switch to a free model to enable reviews on this change. |
|
Adversarial review record (one independent reviewer over the diff; all findings verified before acting): Clean, confirmed by execution: Dispositioned: the reviewer flagged the missing CHANGELOG entry; every merged outside-contributor PR here (#23–#26) left CHANGELOG to release-time backfill, so this PR follows that precedent and carries a suggested entry in the description instead. A pre-existing nit (the converter's block bodies omit |
Bug
convertHtmlToBlocks()emits<!-- wp:heading {"level":N} -->forh1andh3–h6, but a bare<!-- wp:heading -->forh2:To be fair to the original code: bare-for-h2 matches Gutenberg's own canonical serialization (default attributes are omitted). But one implicit case among six explicit ones makes conversion output inconsistent across heading levels — and in the field it reads as data loss: content whose blocks carried an explicit
{"level":2}came back from aconvert_to_blocksround-trip with the attribute gone, reported as "stripped the level off every heading block."Fix
All six heading tags share one case that emits the level explicitly (an explicit default attribute is valid for the block parser; the editor's next save may normalize it back out, which is fine):
Content already in block format is untouched — the pass-through in
processContentruns before the converter, and a test pins that.Tests
tests/tools/html-to-blocks-headings.test.tsdrivescreate_contentwithconvert_to_blocks: truethrough a mocked transport and inspects the written content: all six levels explicit, block body preserved, the markdown route (##→<h2>) covered, and block-format pass-through untouched. 3 of 4 fail against the current implementation (the pass-through test correctly passes on both).Full suite 39 passed / 2 skipped,
tscclean.Suggested CHANGELOG entry (following the repo's release-time backfill convention rather than touching
[Unreleased]in the PR):🤖 Generated with Claude Code
https://claude.ai/code/session_012xFYsxskaCvMkg5mDw2iVH