Repository navigation
feat(media): render a PDF written as an image as a link - #487
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
comark-annotate
comark-badge
comark-bundle
comark-cards
comark-carousel
comark-cast
comark-charts
comark-chat
comark-chips
comark-cjk
comark-code
comark-code-notes
comark-colors
comark-comments
comark-critic
comark-deflist
comark-details
comark-diagrams
comark-diff
comark-embed
comark-fields
comark-figure
comark-file-tree
comark-footnotes
comark-git-graph
comark-github
comark-icon
comark-include
comark-keys
comark-links
comark-linter
comark-magic-move
comark-mark
markdown-it-to-comark
marked-to-comark
comark-mathml
comark-media
comark-metrics
migrate-to-comark
comark-motion
comark-outline
comark-properties
comark-qr
comark-quiz
comark-reading-time
remark-to-comark
comark-sources
comark-steps
comark-table
comark-tabs
comark-tests
comark-time
comark-ui
comark-xref
comark-zoom
commit: |
There was a problem hiding this comment.
Caution
The new PDF branch can turn an unchecked src into a clickable script URL. Fix URL validation before merging; linked images and label handling also need attention.
Approach: Keeping kind: "pdf" in the shared media node makes sense for custom renderers, but converting an image into a link needs to preserve Markdown’s URL checks and link structure.
Reviewed changes across media parsing, all four renderer implementations, and the docs and diagnostics.
- Parsing: Recognizes
.pdfbefore a query or fragment and normalizes it without player settings or measurement. - Rendering: Adds
.cm-pdfanchors in HTML, Vue, React, and Svelte without loading the media runtime for PDF-only documents. - Validation and docs: Extends the media rules, examples, and skill reference. The focused media and Doctor suites passed 349 tests; direct parse/render checks exposed the cases below.
gpt-6.2-sol(high) | 𝕏
Latest result PR closed or outside the configured filter. Final answersSession PR closed or outside the configured filter. Session Pull request evidence changed. Session Pull request evidence changed. Session Pull request evidence changed. Session Pull request evidence changed. Session Pull request evidence changed. |
There was a problem hiding this comment.
Important
The new intermediate tags can make valid PDF links disappear when a host uses the preset’s exported allowlist. Fix that integration before merging.
Reviewed changes since the previous Pullfrog review.
- Validated PDF destinations after attribute resolution and kept authored
kindfrom turning PDF images into players. - Normalized PDF labels from Markdown tokens and replaced PDF images inside links with text, avoiding nested anchors.
- Verified the changes with 443 passing tests across media, Doctor, chips, zoom, and preset suites, plus direct parse, render, and lint checks.
gpt-6.2-sol(high) | 𝕏
There was a problem hiding this comment.
Important
The new metadata fixes the tag allowlist, but the default preset loses the PDF label when it copies a screenshot into a second table cell.
Approach: Keeping the public media tag throughout parsing is the right fix for allowlists; the PDF metadata also needs to survive copies made by the preset.
Reviewed changes in d6be728 since the previous Pullfrog review. The focused media, lint, Doctor, and annotate suites passed 460 tests.
- Moved PDF image metadata onto the public
medianode and verified that the preset’s exported allowlist works withsecurity()on either side of the preset. - Preserved the enclosing link’s label when the unused PDF destination is rejected.
- Improved diagnostic locations for formatted labels, entity-encoded labels, and overridden destinations in the new lint cases.
gpt-6.2-sol(high) | 𝕏
There was a problem hiding this comment.
ℹ️ The screenshot copies now keep their PDF labels. One new P2 finding is inline; no new P0 or P1 findings.
Reviewed changes in 878c0ef since the previous Pullfrog review. The preset build and 152 focused tests passed.
- Made PDF image metadata cloneable without changing the public
mediatag or breaking the preset’s security allowlist. - Added a regression test for two table cells that reference the same screenshot and render its PDF caption with an overridden destination.
gpt-6.2-sol(high) | 𝕏
There was a problem hiding this comment.
✅ No new issues found in
3c60e02. The earlier open threads are unchanged, so this is not an approval.
Reviewed changes in 3c60e02 since the previous Pullfrog review. The preset and linter builds passed, and 166 focused tests passed with one skipped.
- Preserved the bracket label. A PDF image keeps its bracket text and reports an authored
altattribute as unsupported. Empty brackets still trigger the missing-label warning. - Deduplicated screenshot-copy diagnostics. Both thumbnail copies still render their PDF links, but each authored image reports once. Direct lint checks confirmed that two identical authored images still report separately at their source lines.
gpt-6.2-sol(high) | 𝕏
There was a problem hiding this comment.
✅ No new issues found in
3fd74f6, including no new P0 or P1 findings. The existing diagnostic-location thread remains open, so this is not an approval.
Reviewed changes in 3fd74f6 since the previous Pullfrog review. The preset and linter built successfully, 166 focused tests passed with one skipped, and media Vite Doctor reported no warnings or errors.
- Changed PDF occurrence IDs to decimal strings. The preset still renders every screenshot copy, reports each authored PDF image once, and keeps separate diagnostics for identical images authored twice.
gpt-6.2-sol(high) | 𝕏

rendered<img src="cv.pdf" alt="CV">, so the page showed a broken image with the alt text beside it. A browser can't draw a PDF as an image, and nothing reported it.Now comark-media reads a
srcending in.pdf(before any?or#) the way it reads a video: the image becomes amedianode,["media", { kind: "pdf", src: "cv.pdf", label: "CV" }]. Every renderer (HTML, Vue, React, Svelte) draws it as a plain link,<a class="cm-pdf" href="cv.pdf">CV</a>, inline where the image was. A host that wants more, like a viewer that draws the pages, passes its ownmediacomponent and handleskind: "pdf".srcand its label.autoplay,loop,muted,poster,width,height, and any other prop go through the existingcomark/media/unknown-propissue, with a message that says a PDF takes only its label.comark/media/missing-label, as for a video.unplayable-srcnow lists.pdfamong the extensions.The media page gets a PDFs section with a live example, and the package README, keywords, AGENTS.md, the comark-ui skill, and the media Doctor pages mention PDFs.
Evidence
Before/after on Drop: the playground with the media page's PDF example on
main(a broken image) and on this branch (a link), plus the new PDFs section in light and dark.The docs example frame resets link styles, so on the media page the PDF link takes the text color with no underline. The playground and a normal page underline it. I left
.cm-pdfunstyled on purpose.Checks
packages/media/test/media.test.tsandframeworks.test.ts(a lone PDF, a PDF inside a sentence, video options on a PDF, a PDF-only document with no styles or script, the same markup in Vue and React) fail onmain: 5 failed, 16 passed. On this branch all 21 pass.pnpm ready, step by step: format clean, build passes,pnpm check0 errors,pnpm run doctorpasses.pnpm test: 3272 passed and one unrelated timeout inremark-to-comark's CLI test, which only fails on my machine because/tmpholds a stray.git; it passes withTMPDIRoutside it.