Skip to content

Add a ContentDocument to Markdown renderer - #586

Merged
Mearman merged 2 commits into
mainfrom
feat/markdown-renderer
Aug 17, 2026
Merged

Add a ContentDocument to Markdown renderer#586
Mearman merged 2 commits into
mainfrom
feat/markdown-renderer

Conversation

@Mearman

@Mearman Mearman commented Aug 17, 2026

Copy link
Copy Markdown
Member

Closes #565.

renderContentDocumentToMarkdown takes any of the five ContentDocument kinds and returns Markdown text. A wordprocessing document goes straight to buildMarkdownText — markdown-codec already understands that shape natively. Every other kind is flattened into the same ContentBlock vocabulary first, then handed to the identical buildMarkdownText call, so a flattened presentation/spreadsheet/drawing gets list rendering, table-cell diagnostics, front matter, and the style options for free with zero duplicated emission logic:

  • presentation: each slide becomes a level-2 "Slide N" heading section, shapes flattened in slide order
  • spreadsheet: each sheet becomes a level-2 heading plus one GFM table (first visible row as the header, hidden rows/columns excluded)
  • drawing: each page becomes a level-2 "Page N" heading section; vectors have no Markdown representation and are dropped
  • formula: degrades to the same plain-text stand-in buildMarkdownText already uses for an embedded formula block

Every flattening decision is real information loss, so each one reports through an onDiagnostic sink (eight stable markdown-render/* codes) rather than happening silently. Diagnostics from the underlying writer still flow through the ordinary sink option.

Tests are co-located in src/markdown/render.test.ts, modelled on the existing hand-built fixture conventions — all five kinds, all eight codes with severities, the runs-over-displayText and alignment-driven-delimiter table behaviour, hidden-row/column exclusion, the default no-op sink, and option pass-through (lineEnding, frontMatter, signal) on the degrade path.

Generated by Claude Code

Adds src/markdown/render.ts renderContentDocumentToMarkdown, covering all
five ContentDocument kinds rather than just wordprocessing (which
buildMarkdownText/writeMarkdown already handle). A wordprocessing
document goes straight to buildMarkdownText; presentation/spreadsheet/
drawing/formula are flattened into the same ContentBlock vocabulary
first (slides/pages become H2-headed sections, a sheet becomes a GFM
table, a formula becomes its own plain-text stand-in), then handed to
the identical buildMarkdownText call. Every flattening decision reports
through a new onDiagnostic sink rather than happening silently.

Exported from src/index.ts.
Adds src/markdown/render.test.ts, co-located with the renderer and
modelled on the hand-built ContentDocument fixture conventions of
src/layout/sheets.test.ts, src/layout/slides.test.ts, and
src/layout/drawing.test.ts: wordprocessing delegation (byte-identical to
buildMarkdownText, no diagnostics), presentation per-slide headings with
notes dropped, spreadsheet GFM tables (runs-over-displayText precedence,
alignment-driven delimiters, hidden rows/columns excluded, anchored
images/embedded objects reported as dropped, empty-sheet placeholder),
drawing per-page headings with vectors dropped, both formula stand-in
branches, all eight diagnostic codes pinned and severity-checked, the
default no-op sink, and option pass-through (lineEnding, frontMatter,
signal) on the degrade path.
@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: TypeScript

TypeScript / unit

The overall coverage in commit c0be131 in the feat/markdown-render... branch remains at 91%, unchanged from commit ef84b22 in the main branch.

Show a code coverage summary of the most impacted files.
File main ef84b22 feat/markdown-render... c0be131 +/-
src/markdown/render.ts 0% 100% +100%

@Mearman
Mearman merged commit 6a31a4e into main Aug 17, 2026
12 checks passed
@Mearman
Mearman deleted the feat/markdown-renderer branch August 17, 2026 13:41
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.102.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a ContentDocument to Markdown renderer

1 participant