fix: preserve image attributes when a title is present#290
Open
nimonian wants to merge 2 commits into
Open
Conversation
The stringify handler for images returns early on the title branch and
never appends the attribute block, so `{width="200"}`
round-trips to ``, silently dropping width, class, and
every other attribute. The parser is fine (the tree keeps `width`); only
rendering is affected. Attributes-only and title-only images round-trip
correctly, so the two regression cases fail while the two controls pass.
Repro: pnpm --filter comark vitest run test/img-attributes.test.ts
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The image stringify handler returned early on the title branch and never
appended the attribute block, so `{width="200"}`
round-tripped to ``, dropping width, class, and every
other attribute. The parser already keeps them (the tree carries `width`);
only rendering was lossy. Append the attribute block on both branches.
Fixes the failing cases added in the previous commit.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@nimonian is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
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.
Fixes #289.
The image stringify handler returns early on the title branch and never appends the attribute block, so
{width="200"}round-trips to, dropping width, class, and every other attribute. The parser already keeps them (the tree carrieswidth); only rendering was lossy.The fix appends the collected attributes on both branches (one line in
packages/comark/src/internal/stringify/handlers/img.ts).Two commits, so the regression is visible on its own:
Run the test:
Verified against current
main: the new test is 4/4 green with the fix, andresolve-attributes/props/bracketsstay green. Note:test/index.test.tsflakes independently of this change (some specs assert a 10ms parse budget that loses under CPU load), so it can fail intermittently on a cleanmaintoo.🤖 Generated with Claude Code