fix: fold a linked image's trailing magic comment into the image mark - #454
fix: fold a linked image's trailing magic comment into the image mark#454RobinQu wants to merge 1 commit into
Conversation
An image followed by a sizing magic comment folds that comment into the
image mark so it round-trips as source while supplying the width — but
only for a standalone image. Inside a link label
(`[<!-- {"width":N} -->](target)`) the comment was emitted
as plain visible text instead, leaking raw markup into the rendering.
Thread takeMagicComment through walkResolvedLink's image call site, the
same folding the standalone-image path already does, and extract the
per-child dispatch into walkResolvedLinkChild to stay within the
statement limit.
|
@RobinQu is attempting to deploy a commit to the ocavue's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe link-child walker now folds trailing image width comments into image marks within inline link labels. The change preserves surrounding link marks and destinations. A regression test covers the nested image case. ChangesInline link image metadata
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
|
Thanks for pointing this out! I've tweaked it a bit and merged it as #455. |
Problem
An image immediately followed by a sizing magic comment (
<!-- {"width":N,"height":M} -->) folds the comment into the image mark: it round-trips as source and supplies the image's display width. That folding happens for a standalone image, but not for an image inside a link label:Here
walkResolvedLink's image call site never invokedtakeMagicComment, so the comment was emitted as plain visible text — raw<!-- ... -->markup leaking into the rendered document (e.g. after persisting a resized linked image, the comment appears as text right after it).Fix
Thread
takeMagicCommentthroughwalkResolvedLink'sImagebranch — the same folding the standalone-image path already performs — and skip children a previous child has consumed. The per-child dispatch moves intowalkResolvedLinkChildto stay within the statement limit.Test
New case in
inline-text-to-mark-chunks.test.ts:[<!-- {"width":320} -->](/target)folds the comment into a single chunk carryingmdImage(src=u,alt=a,width=320)inside the link label, with no leaked comment text. It fails without the fix. Full@meowdown/coresuite (1622 tests), typecheck, and lint all pass.Summary by CodeRabbit