docs: add a runnable custom conversion rule - #112
Merged
Merged
Conversation
This was referenced Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Developers can supply custom HTML conversion rules, but there was no runnable example showing the hook or its limits. Closes #109.
Solution
Add a small paragraph rule, a guide with the actual CLI output, and a test that imports the shipped example.
examples/custom-rule.mjsdev/test/custom-rule-example.test.tsdocs/extending.mdDiff
+89 −0 · 3 files · no runtime or API changes
Testing & verification
Reviewed revision:
861201e0acec0b573845357e7dc728a884239ab9· Environment: macOS, Node 22.23.1; existing matching dependencies reused.npm run build— passed.npx vitest run dev/test/custom-rule-example.test.ts dev/test/convert.test.ts— passed, 2 files / 6 tests.npx --no-install block-runner convert '<p data-notice>Service update</p>' --config examples/custom-rule.mjs— passed; emitted the documented native paragraph with the notice class.npm run typecheckandnpm run check:private— passed.npm run pack:check— passed; includesexamples/custom-rule.mjs.git diff --cached --check— passed before commit. Reviewed the new guide separately for private references because the packed-file scan excludesdocs/.A fresh installed consumer also ran
npx --no-install block-runner convert '<p data-notice>Service update</p>' --config node_modules/block-runner/examples/custom-rule.mjs --json— passed with one valid native paragraph, zero invalid blocks and no warnings. Its resolved dependency tree emittedclass="notice notice"; the locked checkout emitsclass="notice". The reported block attribute isclassName: "notice"in both. The guide shows the observed checkout output; this PR does not change serialization.Not verified: real-WordPress rendering and third-party block registration. The example establishes conversion and headless validity only; it does not generate CSS. GitHub CI: all three Node lanes and the package check passed. The first WordPress run failed its native style-adapter editor check: the retained receipt records a 1278px viewport where 1280px was required. Attempt 1 evidence is retained. The same runtime code passed on #113.
gh run rerun 34981527836 --failed --repo humanmade/block-runner— passed in attempt 2. All checks passed on the unchanged revision; no test threshold or runtime source was changed.Risk / rollout
The hook forwards this example's simple paragraph content; the guide does not promise sanitisation or arbitrary rich-text support. No dependencies, website files or default rules change.
Detection: the test imports the actual example and checks both inputs. Rollback: revert this commit.
Authored by: GPT-6 via Codex.