hermes - 💡(How to fix) Fix Markdown 表格含 CJK 字符时竖框线无法对齐(同 #20621 根因,不同渲染路径)

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Code Example

| 项目 | 版本号 | 状态 | 说明 |
|------|--------|------|------|
| 前端框架 | 4.2.0 | 已发布 | 支持中文排版 |
| 后端服务 | 3.1.5 | 开发中 | 需要配置数据库 |
| CLI 工具 | 2.0.1 | 已废弃 | 请迁移到新版 |

---

python3 cjk_table_format.py --visual-cjk file.md
RAW_BUFFERClick to expand / collapse

Issue 标题

Markdown 表格含 CJK 字符时竖框线无法对齐(与 #20621 同根因,不同渲染路径)

问题描述

Hermes Agent 在 CLI 模式下输出 Markdown 表格时,如果表格中包含 CJK 字符(中文/日文/韩文)或 emoji,竖框线(|)无法对齐,表格难以阅读。

复现步骤

LLM 生成包含中文的 Markdown 表格时,例如:

| 项目 | 版本号 | 状态 | 说明 |
|------|--------|------|------|
| 前端框架 | 4.2.0 | 已发布 | 支持中文排版 |
| 后端服务 | 3.1.5 | 开发中 | 需要配置数据库 |
| CLI 工具 | 2.0.1 | 已废弃 | 请迁移到新版 |

终端渲染结果中,含 CJK 字符的行 | 竖线向右偏移,列无法对齐。

根因

与 #20621(面板边框 CJK 溢出)相同:len() 计算的是码点数量,但 CJK 字符在终端中渲染宽度为 2 列,而 ASCII 字符为 1 列。len("seco 容器的 gateway") 返回 19,但终端渲染约 25 列,导致 padding 不足。

与 #20621 的关系

#20621 修复了审批面板/clarify 弹窗中 len() 导致的 CJK 溢出问题(使用 _display_width() + wcwidth),但 Markdown 表格走的是不同的渲染路径——LLM 生成的文本直接输出到终端,没有经过 _display_width() 处理,因此表格对齐问题依然存在。

影响范围

  • 任何包含 CJK 内容且由 LLM 生成的 Markdown 表格
  • 中文用户日常使用的主要痛点
  • 终端宽度较窄(80 列)时问题更明显

当前临时方案

使用外部工具 cjk-table-formatter(Hermes skill)对 Markdown 表格做后处理:

python3 cjk_table_format.py --visual-cjk file.md

局限:不是内置行为,表格超宽时仍需手动缩写列名。

建议修复方向

  1. 复用 #20621 的方案:将 _display_width(wcwidth) 扩展到 Markdown 内容的渲染管线
  2. LLM 提示工程:在 system prompt 中提示 LLM 生成表格时为 CJK 列预留额外宽度
  3. 终端宽度感知:检测 $COLUMNS 环境变量,超宽表格自动换行或缩写
  4. 提供配置开关:让用户选择 CJK 补偿策略(关/数学对齐/视觉补偿)

环境

  • OS: Linux Mint 22.3
  • Hermes Agent: CLI 模式(prompt_toolkit)
  • 语言: 中文

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix Markdown 表格含 CJK 字符时竖框线无法对齐(同 #20621 根因,不同渲染路径)