Skip to content

Feat/font and image theme#28

Open
SyrupyTasty wants to merge 11 commits into
vace:mainfrom
SyrupyTasty:feat/font-and-image-theme
Open

Feat/font and image theme#28
SyrupyTasty wants to merge 11 commits into
vace:mainfrom
SyrupyTasty:feat/font-and-image-theme

Conversation

@SyrupyTasty

Copy link
Copy Markdown

Add more theme configurations:

/**
 * Body typography customization
 */
bodySize?: number        // Font size in points (e.g., 14 for 14pt). Optional, uses library default if omitted.
lineSpacing?: number     // Line spacing multiplier (e.g., 1.5 for 150%). Optional, uses library default if omitted.

/**
 * Font family customization
 */
bodyFont?: string        // Font for body/paragraph text (e.g., "Arial", "Times New Roman"). Optional.
headingFont?: string     // Font for headings. Optional.
codeFont?: string        // Font for code blocks, inline code, HTML, and tags. Optional, falls back to "Courier New" in code when unset.
blockquoteFont?: string  // Font for blockquotes. Optional.

/**
 * Image horizontal alignment
 */
imageHorizontalAlign?: "left" | "center" | "right"

/**
 * Image default sizing behavior
 * - "actual": use the image's native pixel dimensions (default)
 * - "auto": scale down only when either dimension overflows the page bounds,
 *   preserving aspect ratio. Never upscale.
 * - "fit": scale so one axis reaches the page bound (may upscale small images),
 *   preserving aspect ratio. Like Word's "fit to page".
 */
imageDefaultSize?: "actual" | "auto" | "fit"

and also updated test snaps since pnpm test failed although source code not modifed.

Changes has been manually reviewed and tested.

@gemini-code-assist gemini-code-assist 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.

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.

Comment thread src/renders/render-image.ts Outdated
Comment thread src/renders/render-paragraph.ts Outdated
Comment thread src/renders/render-image.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/renders/render-image.ts Outdated
Comment thread src/renders/render-paragraph.ts
Comment thread tests/theme-styles.test.ts Outdated
Comment thread src/types.ts Outdated
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.

2 participants