fix(build): copy images referenced only by gallery-src - #2273
Merged
Merged
Conversation
An image can point to a heavier version of itself with the `gallery-src`
option: `{gallery-src=big.png}`. The gallery version is never
rendered inline, and asset collection only looked at link destinations, so
`big.png` was not registered as an asset.
In html output that went unnoticed - it copies the whole input directory.
In md output, which copies only collected assets, the file never reached
the output, and the viewer opened a missing file from S3 when the gallery
was expanded.
Collect `gallery-src` as a separate image asset with the `gallery` subtype,
so it is copied and size-checked like any other image, but is not inlined
by `mergeSvg` (it shares its location with the image it belongs to).
Options of reference images (`![alt][ref]{...}`) are still not parsed at
all, so `gallery-src` on them is not collected either.
martyanovandrey
requested review from
a team and
diplodoc-bot
as code owners
September 15, 2026 16:30
martyanovandrey
requested review from
Yurok868 and
stenin-nikita
and removed request for
a team
September 15, 2026 16:30
|
stenin-nikita
approved these changes
Sep 17, 2026
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.



Problem
An image can point to a heavier version of itself with the
gallery-srcoption:The gallery version is never rendered inline, and asset collection only looked at link destinations, so
mountain.jpgwas never registered as an asset.In html output this went unnoticed:
output-htmlcopies the whole input directory. In md output, which copies only collected assets, the file never reached the output - and the viewer, which serves the md build, answered 404 when the gallery was expanded.Reproduced on the platform docs themselves (
ru/syntax/media.mdindiplodoc-platform/docs, the page that documentsgallery-src):The missing file matches the 404 seen in production:
https://diplodoc.com/docs/docs-assets/diplodoc-platform--docs/rev/<rev>/_images/mountain.jpg.Fix
parseLinkOptionsnow accepts hyphenated option names, sogallery-srcis read asgallerySrcinstead of being truncated to a straysrckey.findLinksInfoderives an extra image asset from everygallery-src, marked with a newgallerysubtype. It shares the location of the image it belongs to, so it is filtered out of code blocks and comments together with it.YFM013) like a regular image, but skipped bymergeSvg- inlining it would replace the rendered image with the gallery version.Notes
Options of reference images (
![alt][ref]{width=100}) are not parsed at all today, sogallery-srcon them is not collected either. That is a separate pre-existing gap; a test pins the current behaviour so whoever fixes option parsing notices it.