Skip to content

Conversation

@pleasebelieveme
Copy link

Description

This PR addresses the CJK (Chinese, Japanese, Korean) text overflow issue in repository cards, as reported in #4678.

The previous logic relied on a third-party library (word-wrap) and specific punctuation (full-width commas), which failed to account for the actual visual width of CJK characters in SVG rendering. This caused text to break the card boundaries or fail to wrap entirely when no punctuation was present.

Key Changes

  • Visual Width-based Wrapping: Implemented a custom implementation that assigns a width of 2 to CJK characters and 1 to Latin characters.
  • Robust Wrapping Logic: The text now wraps dynamically based on cumulative visual width, ensuring it stays within the card boundaries regardless of punctuation.
  • Ellipsis Handling: Added proper handling for maxLines with an ellipsis (...) for truncated text.
  • Dependency Optimization: Removed the word-wrap library as the new custom logic is more accurate and reduces unnecessary dependencies.

Screenshots (Before & After)

Before (Bug) After (Fixed)
Sakurairo Sakurairo_fixed
TikTokDownloader TikTokDownloader_fixed

Note: In the 'After' screenshots, you can see the text correctly wrapping and ending with an ellipsis within the card limits.

Test Results

Passed all 11 tests in tests/fmt.test.js, including the newly added CJK wrapping scenarios.

Note on lockfile

package-lock.json was updated to reflect the removal of word-wrap and to align with the Node.js v22 environment.

@vercel
Copy link

vercel bot commented Jan 25, 2026

@pleasebelieveme is attempting to deploy a commit to the github readme stats Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added repo-card Issues related to the pin/repo card. dependencies Pull requests that update a dependency file gist-card labels Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file gist-card repo-card Issues related to the pin/repo card.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant