Skip to content

feat(media): render a PDF written as an image as a link - #487

Merged
vite-hub[bot] merged 6 commits into
mainfrom
feat/media-pdf
Nov 25, 2026
Merged

vite-hub[bot] merged 6 commits into
mainfrom
feat/media-pdf

Conversation

@onmax

@onmax onmax commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

![CV](cv.pdf) 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 src ending in .pdf (before any ? or #) the way it reads a video: the image becomes a media node, ["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 own media component and handles kind: "pdf".

  • A PDF keeps only src and its label. autoplay, loop, muted, poster, width, height, and any other prop go through the existing comark/media/unknown-prop issue, with a message that says a PDF takes only its label.
  • An empty label reports comark/media/missing-label, as for a video.
  • No size measuring, and no styles or script: a document whose only media is a PDF gets neither. Videos and audio render exactly as before.
  • unplayable-src now lists .pdf among 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-pdf unstyled on purpose.

Checks

  • The new tests in packages/media/test/media.test.ts and frameworks.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 on main: 5 failed, 16 passed. On this branch all 21 pass.
  • pnpm ready, step by step: format clean, build passes, pnpm check 0 errors, pnpm run doctor passes. pnpm test: 3272 passed and one unrelated timeout in remark-to-comark's CLI test, which only fails on my machine because /tmp holds a stray .git; it passes with TMPDIR outside it.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-25T07:16:18.342363Z
We couldn’t complete this review. Comment @codex review to try again.
0ac3548 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@pkg-pr-new

pkg-pr-new Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

comark-annotate

pnpm add https://pkg.pr.new/comark-annotate@487

comark-badge

pnpm add https://pkg.pr.new/comark-badge@487

comark-bundle

pnpm add https://pkg.pr.new/comark-bundle@487

comark-cards

pnpm add https://pkg.pr.new/comark-cards@487

comark-carousel

pnpm add https://pkg.pr.new/comark-carousel@487

comark-cast

pnpm add https://pkg.pr.new/comark-cast@487

comark-charts

pnpm add https://pkg.pr.new/comark-charts@487

comark-chat

pnpm add https://pkg.pr.new/comark-chat@487

comark-chips

pnpm add https://pkg.pr.new/comark-chips@487

comark-cjk

pnpm add https://pkg.pr.new/comark-cjk@487

comark-code

pnpm add https://pkg.pr.new/comark-code@487

comark-code-notes

pnpm add https://pkg.pr.new/comark-code-notes@487

comark-colors

pnpm add https://pkg.pr.new/comark-colors@487

comark-comments

pnpm add https://pkg.pr.new/comark-comments@487

comark-critic

pnpm add https://pkg.pr.new/comark-critic@487

comark-deflist

pnpm add https://pkg.pr.new/comark-deflist@487

comark-details

pnpm add https://pkg.pr.new/comark-details@487

comark-diagrams

pnpm add https://pkg.pr.new/comark-diagrams@487

comark-diff

pnpm add https://pkg.pr.new/comark-diff@487

comark-embed

pnpm add https://pkg.pr.new/comark-embed@487

comark-fields

pnpm add https://pkg.pr.new/comark-fields@487

comark-figure

pnpm add https://pkg.pr.new/comark-figure@487

comark-file-tree

pnpm add https://pkg.pr.new/comark-file-tree@487

comark-footnotes

pnpm add https://pkg.pr.new/comark-footnotes@487

comark-git-graph

pnpm add https://pkg.pr.new/comark-git-graph@487

comark-github

pnpm add https://pkg.pr.new/comark-github@487

comark-icon

pnpm add https://pkg.pr.new/comark-icon@487

comark-include

pnpm add https://pkg.pr.new/comark-include@487

comark-keys

pnpm add https://pkg.pr.new/comark-keys@487

comark-links

pnpm add https://pkg.pr.new/comark-links@487

comark-linter

pnpm add https://pkg.pr.new/comark-linter@487

comark-magic-move

pnpm add https://pkg.pr.new/comark-magic-move@487

comark-mark

pnpm add https://pkg.pr.new/comark-mark@487

markdown-it-to-comark

pnpm add https://pkg.pr.new/markdown-it-to-comark@487

marked-to-comark

pnpm add https://pkg.pr.new/marked-to-comark@487

comark-mathml

pnpm add https://pkg.pr.new/comark-mathml@487

comark-media

pnpm add https://pkg.pr.new/comark-media@487

comark-metrics

pnpm add https://pkg.pr.new/comark-metrics@487

migrate-to-comark

pnpm add https://pkg.pr.new/migrate-to-comark@487

comark-motion

pnpm add https://pkg.pr.new/comark-motion@487

comark-outline

pnpm add https://pkg.pr.new/comark-outline@487

comark-properties

pnpm add https://pkg.pr.new/comark-properties@487

comark-qr

pnpm add https://pkg.pr.new/comark-qr@487

comark-quiz

pnpm add https://pkg.pr.new/comark-quiz@487

comark-reading-time

pnpm add https://pkg.pr.new/comark-reading-time@487

remark-to-comark

pnpm add https://pkg.pr.new/remark-to-comark@487

comark-sources

pnpm add https://pkg.pr.new/comark-sources@487

comark-steps

pnpm add https://pkg.pr.new/comark-steps@487

comark-table

pnpm add https://pkg.pr.new/comark-table@487

comark-tabs

pnpm add https://pkg.pr.new/comark-tabs@487

comark-tests

pnpm add https://pkg.pr.new/comark-tests@487

comark-time

pnpm add https://pkg.pr.new/comark-time@487

comark-ui

pnpm add https://pkg.pr.new/comark-ui@487

comark-xref

pnpm add https://pkg.pr.new/comark-xref@487

comark-zoom

pnpm add https://pkg.pr.new/comark-zoom@487

commit: 3fd74f6

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .pdf before a query or fragment and normalizes it without player settings or measurement.
  • Rendering: Adds .cm-pdf anchors 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread packages/media/src/html.ts Resolved
Comment thread packages/media/src/index.ts Resolved
Comment thread packages/media/src/vue.ts Resolved
Comment thread packages/media/src/index.ts Resolved
@vite-hub

vite-hub Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed 2026-11-25T09:47:24.030Z 1s
View session Last seen running 2026-11-25T09:43:53.984Z 1s
View session Cancelled 2026-11-25T09:28:10.068Z 6m 25s
View session Cancelled 2026-11-25T09:04:12.654Z 6m 4s

Latest result

PR closed or outside the configured filter.

Final answers

Session

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 kind from 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread packages/media/src/index.ts Resolved
Comment thread packages/media/src/index.ts Resolved
Comment thread packages/media/src/index.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 media node and verified that the preset’s exported allowlist works with security() 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread packages/media/src/index.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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 media tag 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

Comment thread packages/media/src/index.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 alt attribute 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.

Pullfrog  | Fix it ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

Pullfrog  | Fix it ➔ | View workflow run | Using gpt-6.2-sol(high) | 𝕏

@vite-hub
vite-hub Bot merged commit f5bf5b0 into main Nov 25, 2026
7 checks passed
@vite-hub
vite-hub Bot deleted the feat/media-pdf branch November 25, 2026 09:47
@github-actions github-actions Bot mentioned this pull request Nov 25, 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.

2 participants