ipynb attachments: preserve image titles, resolve files/ output URLs#64
Merged
Conversation
Three small fixes to the attachment-embedding pipeline from PR #1's review trail: - embedImagesAsAttachments now captures the optional "title" group and re-emits it on the attachment reference (#4) - collectImageData resolves URLs against the export output folder when source-relative resolution fails, so images finalizeMdast writes to files/ (e.g. executed outputs) are embedded instead of skipped (#3) - image reads are async (fs.promises + Promise.all), per the recommendation recorded in #10 Fixes #3 Fixes #4 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR tightens MyST→IPYNB image attachment embedding to handle a few edge cases encountered during notebook export, improving fidelity (titles) and correctness (resolving files/ output assets) while also making image reads non-blocking.
Changes:
- Preserve optional Markdown image titles when rewriting image links to
attachment:references. - Resolve attachment image paths against both the source folder and the export output folder (to catch
files/...assets generated during export). - Switch image file reads to async (
fs.promises.readFile) with concurrent processing.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/myst-to-ipynb/tests/attachments.spec.ts | Adds a unit test ensuring image titles are preserved during attachment rewrite. |
| packages/myst-to-ipynb/src/attachments.ts | Captures and re-emits the optional "title" portion in rewritten attachment: image references. |
| packages/myst-cli/src/build/ipynb/index.ts | Makes image collection async and adds output-folder fallback resolution for files/... URLs. |
| .changeset/ipynb-attachment-fixes.md | Adds a patch changeset documenting the fixes for both myst-cli and myst-to-ipynb. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mmcky
added a commit
that referenced
this pull request
Jun 12, 2026
Records squash a34ab19 as merged feature 13 (untagged) and appends it to the myst-to-ipynb upstream candidate's commits — it fixes edge cases in that feature's own code, so it ships in the same cherry-pick. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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 #3
Fixes #4
Housekeeping batch for the ipynb attachment-embedding edge cases from PR #1's review trail (plus the async-read recommendation from #10, which is being closed alongside).
Changes
embedImagesAsAttachmentsmatched the optional"title"inbut dropped it on rewrite; the title group is now captured and re-emitted:. (Note: titles can still be dropped earlier in the pipeline at parse time — that's outside this serializer fix's scope and Image attachment rewrite drops optional image title #4's report.)files/output-folder resolution.collectImageDataresolved URLs only against the source file's folder, butfinalizeMdastrewrites generated images (e.g. executed notebook outputs) tofiles/...paths that exist only under the export output folder — those were silently skipped. Resolution now falls back to the output folder.collectImageDatausesfs.promises.readFilewithPromise.allinstead of synchronous reads (and drops theexistsSyncTOCTOU check in favor of try/read).Verification
out/files/(previouslyattachments: [], now embedded asattachment:dot.png)🤖 Generated with Claude Code