Feat/font and image theme#28
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces theme customization options for fonts (body, heading, code, and blockquote) and images (alignment and sizing behaviors like "auto" and "fit"). It also implements image scaling logic to fit page margins. The review feedback highlights a critical issue where wrapping images in a new Paragraph inside renderImage results in invalid nested paragraphs in DOCX/OOXML, which can corrupt documents. The reviewer suggests handling image alignment at the paragraph level instead. Additionally, a guard is recommended in scaleImageToFit to prevent division by zero or NaN dimensions if the image has non-positive width or height.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR expands the IMarkdownTheme surface to support font-family customization (body/heading/code/blockquote) and image presentation controls (horizontal alignment and default sizing behavior), and updates documentation/help text plus test coverage to validate the new theme behavior.
Changes:
- Add new theme fields for font families and apply them in default + markdown token styles.
- Add theme-driven image paragraph alignment and image sizing modes (
actual/auto/fit) during rendering. - Update CLI help text, sample config, and test suite (including snapshots) to reflect the new configuration options.
Reviewed changes
Copilot reviewed 10 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/theme-styles.test.ts | Adds unit tests for new font options and image alignment/sizing behavior. |
| tests/theme-CLI.test.ts | Ensures CLI help output includes the new theme keys. |
| tests/index.test.ts | Extends config fixture to include the new theme fields. |
| src/types.ts | Extends IMarkdownTheme with font-family and image config options + docs. |
| src/styles/styles.ts | Applies bodyFont at the document default run style level. |
| src/styles/markdown.ts | Applies headingFont, codeFont, and blockquoteFont in markdown token styles. |
| src/renders/render-paragraph.ts | Adds theme-based alignment for single-image paragraphs. |
| src/renders/render-image.ts | Adds imageDefaultSize handling via scaleImageToFit and explicit-size detection. |
| src/snapshots/tokenize.test.ts.snap | Updates snapshots for image token structure changes. |
| examples/sample-config.json | Updates sample config to include the new theme settings. |
| bin/help-texts.mjs | Documents new theme options in CLI help text. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add more theme configurations:
and also updated test snaps since
pnpm testfailed although source code not modifed.Changes has been manually reviewed and tested.