Skip to content

Improve MD060 wide-character coverage (arrows, rare CJK, fullwidth forms) - #2208

Open
seeones wants to merge 1 commit into
DavidAnson:mainfrom
seeones:fix/md060-wide-char-coverage
Open

Improve MD060 wide-character coverage (arrows, rare CJK, fullwidth forms)#2208
seeones wants to merge 1 commit into
DavidAnson:mainfrom
seeones:fix/md060-wide-char-coverage

Conversation

@seeones

@seeones seeones commented Aug 5, 2026

Copy link
Copy Markdown

Background

MD060 (table-column-style) computes each table column's visual width with the string-width package. In practice, arrows such as ↑ ↓ ← → (U+2190–U+21FF) and some wide characters outside the common CJK ranges (rare ideographs like 𠀀, , vertical forms, fullwidth signs, etc.) are not always measured as double-width, so "aligned" tables containing them are still reported/mis-fixed.

Changes

  • lib/md060.mjs: replace the string-width import with a local visualWidth() helper — grapheme-cluster count via Intl.Segmenter (Node ≥16, well within the required Node ≥22) plus an explicit UAX Rule MD004 incorrectly flagging on an Ordered List #11 Wide/Fullwidth character class. The class additionally covers arrows (U+2190–U+21FF), which are "Ambiguous" in UAX Rule MD004 incorrectly flagging on an Ordered List #11 but render double-width in CJK contexts/terminals.
  • test/table-column-style-wide-characters.md: add Arrows and Rare CJK sections; test/markdownlint-test-scenarios.mjs.snapshot updated accordingly.

To keep this PR minimal, package.json is intentionally untouched — string-width is no longer imported anywhere and its dependency entry can be dropped in a follow-up at the maintainer's discretion.

Testing

  • node --test test/markdownlint-test-scenarios.mjs (408 tests) and the remaining snapshot suites (119 tests) pass.
  • eslint --max-warnings 0 lib/md060.mjs passes.

Related

The same width-calculation approach is used by the table formatter in vscode-markdown (Markdown All in One), which had the identical coverage gap. A corresponding fix has already been submitted there and is open for review:

…rms)

Replace the string-width dependency with a local visualWidth helper based on Intl.Segmenter plus an explicit UAX DavidAnson#11 Wide/Fullwidth character class, so table column alignment also handles arrows (U+2190-U+21FF), Hangul Jamo, CJK extensions/rare ideographs, vertical forms, and fullwidth symbols. Adds arrow and rare-CJK cases to the wide-character table test and updates its snapshot.
@DavidAnson

Copy link
Copy Markdown
Owner

If the string-width package is handling these characters incorrectly, please open an issue with that project. That will improve all projects that use it vs. requiring separate changes everywhere.

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