Add a ContentDocument to Markdown renderer - #586
Merged
Conversation
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.
Contributor
|
🎉 This PR is included in version 1.102.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #565.
renderContentDocumentToMarkdowntakes any of the fiveContentDocumentkinds and returns Markdown text. Awordprocessingdocument goes straight tobuildMarkdownText— markdown-codec already understands that shape natively. Every other kind is flattened into the sameContentBlockvocabulary first, then handed to the identicalbuildMarkdownTextcall, 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:buildMarkdownTextalready uses for an embedded formula blockEvery flattening decision is real information loss, so each one reports through an
onDiagnosticsink (eight stablemarkdown-render/*codes) rather than happening silently. Diagnostics from the underlying writer still flow through the ordinarysinkoption.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