Skip to content

Fix two problems with image links caused by regex fix - #134

Merged
andrew-polk merged 1 commit into
mainfrom
fix-image-link-double-bang
Jun 25, 2026
Merged

Fix two problems with image links caused by regex fix#134
andrew-polk merged 1 commit into
mainfrom
fix-image-link-double-bang

Conversation

@andrew-polk

@andrew-polk andrew-polk commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

This change is Reviewable

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Commit 2e2cdd2 made regex markdown replacements fire on every match
(correctly), which exposed two latent problems in the gif/imgur embed
plugins:

1. Double "!": once imgur turned a link into an image, the gif mod
   matched that image and prepended a second "!", giving "!![](...)".
2. Authored links eaten: the plugins turned ANY matching link into an
   image -- including inline links the author gave descriptive text,
   e.g. [see animation](https://imgur.com/x) -- discarding the text and
   the clickable link. (Before 2e2cdd2 such links were only spared by a
   nondeterministic index-drift bug, never a real rule.)

Fix both by only embedding links whose text is an AUTO-GENERATED label,
not author prose. The embed regex can see three auto shapes by the time
it runs: empty "[]", the literal "[bookmark]" placeholder, and -- in the
production config -- the URL repeated as the label, "[http...](http...)",
which standardExternalLinkConversion rewrites "[bookmark]" into in an
earlier phase (doLinkFixes, see transform.ts). An optional leading "!"
also lets us match an already-imaged link without doubling the "!".

Tests: cover the double-bang and imgur+gif interaction, authored links
staying clickable, and the production path (bookmark -> [url](url) ->
embed) both with standardExternalLinkConversion and through the actual
default production config, so future config drift can't reopen this.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@andrew-polk
andrew-polk force-pushed the fix-image-link-double-bang branch from d8529eb to 3520700 Compare June 25, 2026 22:10
@andrew-polk
andrew-polk merged commit a40fa1c into main Jun 25, 2026
1 of 2 checks passed
@andrew-polk
andrew-polk deleted the fix-image-link-double-bang branch June 25, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant