Update MD060/table-column-style to account for emoji and CJK characters rendering at 2x Latin width (fixes #1869).

This commit is contained in:
David Anson 2025-11-25 14:15:50 -08:00
parent ec380a87c0
commit 9b116ae889
13 changed files with 254 additions and 61 deletions

View file

@ -1,9 +1,9 @@
This rule is triggered when the column separators of a
[GitHub Flavored Markdown table][gfm-table-060] are used inconsistently.
This rule recognizes three table column styles based on popular use:
This rule recognizes three table column styles based on popular use.
Style `aligned` looks the most like a table:
Style `aligned` ensures table delimiters are vertically aligned:
```markdown
| Character | Meaning |
@ -12,7 +12,16 @@ Style `aligned` looks the most like a table:
| N | No |
```
Style `compact` uses a single space to pad cell content:
The `aligned` style ignores cell content, so the following is also valid:
```markdown
| Character | Meaning |
|-----------|---------|
| Y | Yes |
| N | No |
```
Style `compact` avoids extra padding with a single space around cell content:
```markdown
| Character | Meaning |
@ -21,7 +30,7 @@ Style `compact` uses a single space to pad cell content:
| N | No |
```
Style `tight` uses no padding for cell content:
Style `tight` uses no padding at all for cell content:
```markdown
|Character|Meaning|
@ -31,16 +40,18 @@ Style `tight` uses no padding for cell content:
```
When this rule's `style` parameter is set to `aligned`, `compact`, or `tight`,
every table must match the corresponding pattern and errors will be reported for
any violations. By default, or when the `any` style is used, each table is
analyzed to see if it satisfies any supported style. If so, no errors are
reported. If not, errors are be reported for whichever style would produce the
*fewest* errors (i.e., whichever style is the closest match).
every table must match the corresponding pattern and any violations will be
reported. By default, or when the `any` style is used, each table is analyzed to
see if it satisfies any supported style. If so, no violations are reported. If
not, violations are be reported for whichever style would produce the *fewest*
issues (i.e., whichever style is the closest match).
Note: Pipe alignment for the `aligned` style is based on character count, so
wide characters and multi-character encodings can produce unexpected results.
The following table is correctly aligned based on character count, though some
editors render the emoji wider:
Note: Delimiter placement for the `aligned` style is based on visual appearance
and not character count. Because editors typically render [emoji][emoji] and
[CJK characters][cjk-characters] at *twice* the width of
[Latin characters][latin-script], this rule takes that into account for tables
using the `aligned` style. The following table is correctly formatted and will
appear aligned in most editors and monospaced fonts:
<!-- markdownlint-capture -->
<!-- markdownlint-disable extended-ascii -->
@ -48,12 +59,15 @@ editors render the emoji wider:
```markdown
| Response | Emoji |
| -------- | ----- |
| Yes | ✅ |
| No | ❎ |
| Yes | ✅ |
| No | ❎ |
```
<!-- markdownlint-restore -->
Rationale: Consistent formatting makes it easier to understand a document.
[cjk-characters]: https://en.wikipedia.org/wiki/CJK_characters
[emoji]: https://en.wikipedia.org/wiki/Emoji
[gfm-table-060]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/organizing-information-with-tables
[latin-script]: https://en.wikipedia.org/wiki/Latin_script