Add core/media-text support to the php-transformer - #814
Merged
Conversation
Honor resolved CSS cascade semantics for media-text layout gates, preserve carrier-owned geometry dependencies, and clamp representable widths. Add regressions for inline display modes, order and reversal rules, geometry carriers, data URLs, memoization, CSS importance, specificity, and invalid declarations.
…view ## Summary Close the fail-open gaps two adversarial review passes found in media-text conversion, and integrate the pattern with trunk's author-owned layout preservation after the rebase. ## Why The strict gates read absent style values as defaults, so design-token var() layouts, ancestor RTL, floated panes, and inexpressible grid templates silently converted with the wrong pane order or width. After the rebase, trunk's author-owned-layout interception also consumed every candidate before the media-text dispatch was reached, and containers with no authored horizontal CSS converted into side-by-side layouts their sources never render. ## How - Dispatch media-text before author-owned layout preservation and remove the now-unreachable later dispatch site - Require an authored horizontal mechanism (display:flex/grid, a usable grid template, or round-trip wp-block-media-text markup) before converting - Resolve text direction through inheritance (ancestor dir attributes and inherited CSS direction; dir="auto" fails closed) - Decline floated panes, unresolvable var() gate values, and grid templates that cannot express a mediaWidth; derive complement widths for an auto media track beside a percentage text track - Run width gates before text-side conversion so declines stop double-converting the subtree and leaking block-binding occurrence counts - Hoist text-side wrapper groups only when their sole classes are transformer-generated css-owned markers absent from source markup - Drop linkTarget/rel/linkClass when the href is rejected as unsafe - Accept media-text state classes in the save-shape validator only when the corresponding attributes justify them - Diagnostics: single-scan at-rule skip, nested-candidate dedup, memoized inherited-direction walk, and PCRE or transform failures counted as diagnostic errors instead of declines ## Testing - [ ] composer test:unit && composer test:parity && composer test:canonical - [ ] php tools/visual-parity/tests/transform-media-text.php - [ ] composer corpus-diagnostics reports media-text counters unchanged from baseline
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.
Summary
Adds native
core/media-textrecognition to the php-transformer: strict two-pane image/video + text containers with an authored horizontal mechanism (display:flex/grid, a usable grid template, or round-tripwp-block-media-textmarkup) now emitcore/media-textwith core's canonical save shape, instead of falling through to columns/group handling.What's included
MediaTextPattern): exactly two element children, one pure img/video side (figure/div/a/picture wrappers allowed; figcaption declines), text-bearing other side. EmitsmediaPosition,mediaWidth(percentage, fr-ratio, orauto-beside-percentage complement, clamped 15–85),verticalAlignment, and safe link attributes.var()layout values, inherited RTL (ancestordir, inherited CSSdirection,dir="auto"), reversed/vertical flex, authored childorder, linked video, unsafe URLs (scheme allowlist;data:imageminus SVG for media), and grid templates that cannot express amediaWidthall decline into the existing columns/group/author-layout paths.BlockFactory): core save shape with supported style groups only (border/color/elements/spacing/typography); defaults omitted;grid-template-columnsemitted core-style.Review
Built through a gated architect/builder loop (35 frozen gates), then hardened by three adversarial review passes whose findings (silent pane swaps under design-token
var()layouts, ancestor RTL, floats, px-track grids; rejected-href metadata retention; validator allowlist gaps; diagnostics accuracy/perf) are all fixed here. Corpus diagnostics report an unchanged baseline:blocks=57765 native_rate=99.7%, media-text counters identical before/after.Testing
composer test:unit,composer test:parity,composer test:canonical— all passphp tools/visual-parity/tests/transform-media-text.php— desktop/mobile visual-parity target renderscomposer corpus-diagnostics— media-text counters unchanged from baseline