Skip to content

Format D2 fences in Markdown and make stdin formatting safe - #3052

Merged
alixander merged 3 commits into
masterfrom
codex/formatter-markdown-stdin
Nov 26, 2026
Merged

alixander merged 3 commits into
masterfrom
codex/formatter-markdown-stdin

Conversation

@alixander

Copy link
Copy Markdown
Collaborator

Human


AI

  • Format only fenced d2 blocks in .md and .markdown files. Preserve surrounding Markdown, fence markers and line endings, including within lists and blockquotes.
  • Add d2 fmt --diff for a read-only unified diff. Combine it with --check to fail CI when formatting is needed.
  • Always write the formatted source on successful d2 fmt -, including unchanged input. Syntax errors leave stdout empty. This follows the behavior proposed in cli: fmt: always output content when formatting stdin #2718 by oliverpool.

Verified with formatter, parser and CLI tests, targeted race and CLI end-to-end tests, and process-level checks of stdout, stderr and patch application. Markdown diagnostics point to the original file and do not write a partial update.

Closes #1577.

  • sent from alixander's Codex

Support read-only unified diffs for CI. Return the full formatted source on successful stdin formatting, including unchanged input, following the behavior proposed in #2718.

- sent from alixander's Codex
- sent from alixander's Codex
@alixander
alixander merged commit 0b22bc1 into master Nov 26, 2026
19 checks passed
@alixander
alixander deleted the codex/formatter-markdown-stdin branch November 26, 2026 12:54
alixander added a commit that referenced this pull request Nov 26, 2026
Master formats D2 fences in Markdown and stdin safely (#3052), adding
github.com/aymanbagabas/go-udiff. go.mod keeps it and this branch's
replacement of andybalholm/brotli by d2lang/brotli.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

fmt from stdout should always output the formatted diagram

1 participant