Skip to content

feat(social): postMarkdown() and threadMarkdown() write fetched posts as Markdown - #505

Merged
vite-hub[bot] merged 2 commits into
mainfrom
feat/social-post-markdown
Nov 28, 2026
Merged

vite-hub[bot] merged 2 commits into
mainfrom
feat/social-post-markdown

Conversation

@onmax

@onmax onmax commented Nov 28, 2026

Copy link
Copy Markdown
Owner

Drop renders documents without fetching, so a script that fetched a post with fetchPost() has to write the ::post Markdown itself. Today it copies the props, the escaping, and the fence rules by hand, and one missed escape breaks a card. comark-social now does it.

What changed

  • postMarkdown(post, { src, colons }) returns the ::post Markdown for what fetchPost() returns, or the same shape written by hand.
  • threadMarkdown(posts, { src, colons, focal }) returns the ::thread Markdown for a thread's posts, root first, each written as postMarkdown() writes it.
  • textMarkdown(text) escapes plain text the same way, for a host that writes text into a block of its own.
  • The renderer now draws an image written with {video} as a video still (.csl-video), which is what the fetch path draws for a video. Without this, a written card had no way to say a picture was a video.
  • Docs: a "Write a post from a script" section on the Social page, covering threads too, plus three rows in its Functions table. The comark-ui skill's social reference covers the same.

Decisions

  • Same card as fetching. The test renders ::post{url} with fetch on and renders postMarkdown() of the same post unfetched, then compares the HTML byte for byte. That covers the X, Bluesky, and Mastodon fixtures and a list of adversarial texts, with social alone and with the whole comark-ui preset. Links therefore read as the fetch path shows them: no scheme, cut after 30 characters.
  • Props are read back exactly. A prop goes in double quotes, or in single quotes when it holds ". When it holds both quotes, a backslash, or a line break, it's written as a :key='…' JSON binding, because Comark's quoted values have no escapes.
  • Text is escaped, not fenced. Markdown syntax in the text gets a backslash: {, ], :name, ::, `, *, $, @ after a character, ://, and a #, -, >, 1., = or : at the start of a line. Spaces at the ends of a line are written as entities, so the text comes back as it went in. \ and [ are written as \ and [, because comark-mathml reads \[ as display math even after an escaped backslash. A link's address is percent-encoded where Markdown links are, which reads the same but isn't byte-equal.
  • src is async and per picture. src(url, { kind, index, post }) covers both the avatar and the pictures, so a script can save each file and write ./A.png, as Drop's publish images expects. Returning undefined keeps the address.
  • What the card leaves out isn't written: a fifth picture, and the quoted post's own quote. platform is written only when the address doesn't already say it.
  • colons opens the block deeper, so a post can go inside another block. The quoted post is always one colon deeper.
  • threadMarkdown() takes the posts, not an address. comark-social has no thread fetcher of its own (the walk is inside the plugin), so the docs show the five-line replyTo loop that builds the list. Each post's quote goes one colon deeper than the post, and src gets the post with each picture, so a script can name files per post. The test fetches a Mastodon thread both ways and compares the HTML.

How it was checked

  • comark-social: 39 tests in test/markdown.test.ts, including the X, Bluesky, and Mastodon fixtures and a fetched Mastodon thread, each rendered both ways and compared byte for byte. The package's other suites pass too (85 tests in all).
  • comark-ui: test/social-markdown.test.ts renders eight adversarial texts through the whole HTML preset (math, mark, keys, critic, footnotes, cite, time, icon, qr, deflist, callouts, code groups, mentions, references, chips, and CJK emphasis) both ways, and compares the HTML.
  • comark-linter's social tests pass.
  • vp fmt, vp check, pnpm typecheck, the social build with publint, pnpm --filter comark-social run doctor (0 warnings), and pnpm run lint:docs all pass.
  • I checked the rendered card and thread in light and dark (screenshots in the evidence).

Plan: https://drop.vitehub.dev/d/wtn1zg3tajmt/social-poll-drop-plan

🤖 Generated with Claude Code

@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-28T16:58:59.305516Z
We couldn’t complete this review. Comment @codex review to try again.
0d926e1 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.

@onmax

onmax commented Nov 28, 2026

Copy link
Copy Markdown
Owner Author

Before/after on Drop

@pkg-pr-new

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

Copy link
Copy Markdown

Open in StackBlitz

comark-annotate

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

comark-badge

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

comark-bundle

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

comark-cards

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

comark-carousel

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

comark-cast

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

comark-charts

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

comark-chat

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

comark-chips

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

comark-cjk

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

comark-code

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

comark-code-notes

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

comark-colors

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

comark-comments

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

comark-critic

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

comark-deflist

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

comark-details

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

comark-diagrams

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

comark-diff

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

comark-embed

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

comark-fields

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

comark-figure

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

comark-file-tree

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

comark-footnotes

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

comark-git-graph

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

comark-github

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

comark-icon

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

comark-include

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

comark-keys

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

comark-links

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

comark-linter

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

comark-magic-move

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

comark-mark

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

markdown-it-to-comark

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

marked-to-comark

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

comark-mathml

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

comark-media

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

comark-metrics

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

migrate-to-comark

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

comark-motion

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

comark-outline

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

comark-properties

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

comark-qr

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

comark-quiz

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

comark-reading-time

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

remark-to-comark

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

comark-social

pnpm add https://pkg.pr.new/comark-social@505

comark-sources

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

comark-steps

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

comark-table

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

comark-tabs

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

comark-tests

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

comark-time

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

comark-ui

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

comark-xref

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

comark-zoom

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

commit: d7018af

@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

Two serialization bugs can change what an unfetched card displays: a text link can become an image, and a real photo can disappear because of its alt text.

Approach: Serializing to the existing ::post and ::thread blocks is the right fit for hosts that render without fetching, but the output needs to preserve links and pictures through the Markdown parser.

Reviewed changes — Traced the new public helpers from fetched data through Markdown parsing and HTML rendering. The workspace build and 94 focused tests passed; targeted round-trip checks reproduced both findings inline.

  • Serialization: Reviewed postMarkdown(), threadMarkdown(), and textMarkdown(), including nesting, quote handling, and picture URL rewrites.
  • Rendering: Reviewed the written {video} path and compared static cards with cards rendered from stubbed platform responses.
  • Documentation: Checked the public examples and agent reference against the new API.

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

Comment thread packages/social/src/markdown.ts Resolved
Comment thread packages/social/src/markdown.ts Resolved
@vite-hub

vite-hub Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —
View session Last seen running 2026-11-28T17:46:08.106Z 1s
View session Cancelled 2026-11-28T17:26:09.055Z 9m 18s
View session Failed 2026-11-28T17:16:42.623Z 4s
View session Failed 2026-11-28T17:08:05.700Z 28s

Latest result

Pull request merged.

Final answers

Session

Pull request merged.

Session

CI reconciliation completed; model work is waiting for host admission.

@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 P0 or P1 findings. The existing alt-text round-trip thread remains open.

Reviewed changes — Reviewed d7018af against the prior review. The full preset built successfully, and all 98 focused social, preset, and linter tests passed.

  • Escaped punctuation before generated links. Verified that an adjacent ! stays visible and the URL renders as a link rather than an image.
  • Changed how image descriptions are serialized and read back. Verified that the original cases involving brackets, mixed quotes, trailing backslashes, and embedded newlines now match the fetched card.

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

@vite-hub
vite-hub Bot merged commit 87efb33 into main Nov 28, 2026
7 checks passed
@vite-hub
vite-hub Bot deleted the feat/social-post-markdown branch November 28, 2026 17:50
@github-actions github-actions Bot mentioned this pull request Nov 28, 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.

1 participant