Skip to content

fix(markdown): rewrite stable file references in HTML srcset - #4612

Open
Valley-15 wants to merge 1 commit into
GitbookIO:mainfrom
Valley-15:fix/4593-markdown-image-urls
Open

Valley-15 wants to merge 1 commit into
GitbookIO:mainfrom
Valley-15:fix/4593-markdown-image-urls

Conversation

@Valley-15

@Valley-15 Valley-15 commented Sep 15, 2026

Copy link
Copy Markdown

Summary

When generating Markdown versions of published pages, stable /files/:id references inside raw HTML srcset attributes were not being rewritten to their resolved file URLs.

This caused image URLs such as:

to remain as /files/:id references in the generated Markdown instead of resolving to the actual file URL.

This change updates the existing HTML reference rewriting logic to also resolve srcset attributes using the same content-reference resolution already used for HTML src attributes.

Changes

  • Rewrite stable /files/:id references in HTML srcset attributes.
  • Keep the existing HTML src reference behavior unchanged.
  • Add regression tests covering both HTML src and srcset file references.

Fixes #4593.

Validation

  • bun test packages/gitbook/src/lib/markdownPage.test.ts
  • bun run --cwd packages/gitbook unit
  • bun run format:check
  • bun run lint
  • bun run --cwd packages/gitbook typecheck
  • git diff --check

All checks pass.

@changeset-bot

changeset-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: b44fcec

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Valley-15
Valley-15 force-pushed the fix/4593-markdown-image-urls branch from 138d2d3 to b44fcec Compare September 15, 2026 06:17
@Valley-15 Valley-15 changed the title fix(markdown): rewrite image srcset file references fix(markdown): rewrite stable file references in HTML srcset Sep 15, 2026
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.

Image URLs are broken when Markdown versions of published docs

1 participant