Skip to content

fix(site): 中文标点后的加粗/斜体正常闭合(0.7.85) - #83

Merged
qiansc merged 1 commit into
mainfrom
feat/site-cjk-emphasis
Oct 25, 2026
Merged

qiansc merged 1 commit into
mainfrom
feat/site-cjk-emphasis

Conversation

@qiansc

@qiansc qiansc commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Summary

修复网站中文加粗:**用 MCP 还是知识包?**不在… 这类写法在页面上原样显示星号。发布 0.7.85。

Compatibility

无数据或接口兼容影响。旁边没有 CJK 字母的 */_ 渲染结果与此前完全一致;旧 CLI 构建的网站在下一次 context build 时自动重新渲染(PACKAGE_SITE_VERSION 已包含渲染配置与 CLI 版本)。

Verification

见下方「自测情况」。

Checklist

  • bun run verify:full passes.(本地跑了 bun run build、typecheck、lint 与 context-cli 全量 bun test,见自测情况;完整 verify:full 由 CI 执行)
  • Lifecycle changes include route and recovery tests.(不涉及)
  • Published package metadata and local pack behavior were checked when affected.
  • English and Simplified Chinese user documentation remain behaviorally equivalent.(未改用户文档)
  • Runtime code remains compatible with Node.js 20+.
  • No generated output, secrets, private sources, or local workspaces are included.

背景

CommonMark 规定:结束的 ** 前面是标点(如 ?、)、、)时,后面必须是空白或标点才能闭合强调。中文标点后通常直接接汉字,因此 **用知识包还是 MCP?**在本地写代码 不会加粗,星号原样输出;有时还会与后面的加粗错配,生成嵌套的 <strong>。VitePress 使用的 markdown-it 严格遵循该规则,问题来自规范对 CJK 不友好,而不是写法错误。

改动

  • packages/context-cli/src/project/packageSiteTheme.ts:网站 markdown 配置中按实例替换 inline State 的 scanDelims:分隔符外侧是汉字、平假名、片假名或谚文字母时,按空白处理来判断左/右侧翼;两侧都没有 CJK 字母时直接返回 markdown-it 原结果。不新增依赖。
  • 新增 siteCjkEmphasis.test.ts。
  • 版本升至 0.7.85(bun.lock 只改 workspace 版本行);CHANGELOG 补记 feat(package): context-knowledge-query 按证据链查询 #82 的证据链 Skill。

风险

只影响网站 HTML 渲染;包内 Markdown、llms 文本、搜索语料的分词不受影响。可能的变化仅限「标点 + ** + CJK 字母」这类原本渲染失败的位置。

向后兼容

现有工作区无需任何操作;升级后下一次构建会重新渲染网站。英文及无 CJK 相邻的内容输出不变。

自测情况

  • siteCjkEmphasis.test.ts:中/日/韩及扩展区汉字共 6 个修复用例;13 个英文、代码风格与混排用例(a * b * c、snake_case、__init__、2*3*4 等)与原生 markdown-it 输出逐字相同。
  • context-cli bun test:1357 pass;4 个失败(cli.test.ts 插件安装 2 个、statusReadCost、productionReadReuse)在未修改的 main 上同样失败,与本改动无关。
  • bun run build、typecheck、release:prepare 通过;lint 0 error。
  • 编译结果对比:用已发布的 0.7.84 与按发布形态打包安装的 0.7.85 分别从同一干净检出构建 portal:607 个文件一一对应,去除资源哈希后唯一差异是 Skill 的 version 行;搜索索引文档、字段与 17,608 个词条完全一致(仅文档顺序不同)。另在一个以中文为主的知识站点上对比,只有含该写法的 2 个页面变为正确加粗,其余内容不变。

🤖 Generated with Claude Code

CommonMark only closes `**...**` after punctuation such as `?` when
whitespace or more punctuation follows, so Chinese like `**用 MCP?**在`
rendered its asterisks literally. The site renderer now treats a CJK
letter on the outer side of a delimiter run like whitespace; runs with
no CJK letter beside them keep the standard result. The changelog also
records the evidence-chain context-knowledge-query Skill from #82.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qiansc
qiansc merged commit 81901de into main Oct 25, 2026
2 checks passed
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.

1 participant