Turns ragged Markdown tables into aligned ones: every column is padded by display width — CJK characters count as two columns, combining marks as zero — so a table full of Chinese text lines up in the editor.
Two modes: align & beautify pads every cell to the column width (keeping :--- alignment markers), compact strips the padding down to single spaces. The rendered result is identical either way — formatting changes source readability, not output.
Frequently asked questions
Why not just count characters?
JavaScript's .length counts UTF-16 code units: a surrogate-pair emoji counts as 2, a Chinese character as 1, but both render two columns wide. Display width needs the Unicode East Asian Width tables.
Does it change how the table renders?
No. Markdown ignores the spaces around cell content and the exact position of pipes — alignment is purely for the human reading the source.
中文说明
把参差不齐的 Markdown 表格排整齐:每列按显示宽度填充——汉字算两列、组合符号算零宽——满表格的中文在编辑器里也能对得笔直。
两种模式:等宽对齐把每个单元格填充到列宽(保留 :--- 对齐标记),紧凑模式把填充压回单空格。两种模式的渲染结果完全相同——格式化只改源码可读性,不改输出。
常见问题
为什么不直接数字符?
JavaScript 的 .length 数的是 UTF-16 码元:代理对 emoji 算 2、汉字算 1,但渲染时都占两列。显示宽度要查 Unicode 东亚宽度表。
会改变表格的渲染结果吗?
不会。Markdown 忽略单元格内容周围的空格与竖线的确切位置——对齐纯粹是给读源码的人看的。