Repository navigation
Commit 23d61fa
fix(plugin-markdown): bold ending in full-width punctuation renders bold before a CJK letter (#36968)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBDHJBvzScLgkhKgms97sNuU)_
repo:objectstack#3 · os-support-ai · session_01WGufzhoBbwh8URjwQHde8v
Fixes #36946
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:控制台帮助手册里,中文粗体以全角标点()。:结尾、后面紧跟中文字时,不再显示成带星号的原文,而是正常加粗;英文手册与聊天不变。
- 为什么做:聊天里同样的问题上周已修好,手册阅读器走的是另一条渲染链没跟上;这次让两处用同一条中日韩强调规则,HotCRM 中文手册里 17
处受影响的句子随之恢复。
- 出错会怎样:只影响手册正文的粗体与斜体识别,安全过滤照旧;若有误判,读者看到的是粗体范围不对,可直接撤回本改动。
- 要你做什么:无。
## What changes
- **Measured first: the manual reader renders through
`@object-ui/plugin-markdown`.** The docs page
(`ui/apps/console/src/pages/DocPage.tsx`) draws the article body with
`MarkdownRenderer` from `@object-ui/plugin-markdown`, which lazy-loads
`MarkdownImpl`. Its remark chain was `[remarkGfm, remarkAlert]`, so the
card's premise holds.
- `MarkdownImpl.tsx` now runs `remark-cjk-friendly/parseOnly` first:
`[remarkCjkFriendly, remarkGfm, remarkAlert]`. This is the rule the chat
surface already runs. It goes first, as in chat's `remarkPluginsBefore`
slot, so it owns the emphasis (attention) tokenizer. `parseOnly` because
this renderer never serializes markdown, the reason chat's docblock
gives.
- `@object-ui/plugin-markdown` adds the dependency `remark-cjk-friendly`
at `^2.3.4`, the same range plugin-chatbot pins. The lockfile gains one
importer entry and no new package: the version resolves to the snapshot
plugin-chatbot already uses.
- **One rule, two import sites, chosen on purpose.** plugin-chatbot does
not depend on plugin-markdown, and plugin-markdown does not depend on
plugin-chatbot (both depend only on `components`/`core`/`types`, plus
`i18n`/`react` for chatbot). One shared exported helper would mean a new
cross-package dependency: chatbot pulling in mermaid and the rehype
chain, or markdown pulling in streamdown. The config shapes also differ
(a streamdown `PluginConfig` against react-markdown `remarkPlugins`). So
each package imports the plugin once, and each site's comment names the
other. `chatMarkdownPlugins.ts` changes a comment only.
- **The sanitize schema is not widened.** The plugin swaps the micromark
attention construct and nothing else, so it can only produce mdast
`strong`/`emphasis` nodes. Those become the `strong`/`em` elements the
default schema already allows, and `rehypeSanitize` still runs last in
the rehype chain. A pin shows the rendered tag set for a CJK bold line
is exactly `div`, `p`, `strong`. A second pin shows raw HTML with an
event handler, and a `javascript:` link, stay stripped inside a CJK bold
run.
- One changeset (`.changeset/36946-manual-reader-cjk-bold.md`), patch,
lists both published packages the diff touches:
`@object-ui/plugin-markdown` (the fix) and `@object-ui/plugin-chatbot`
(comment only).
**Read first, by risk:**
1. `ui/packages/plugin-markdown/src/MarkdownImpl.tsx`: the
`remarkPlugins` line and its comment block. This is the only behaviour
change.
2. `ui/packages/plugin-markdown/src/markdown-render.test.tsx`: the new
`bold next to CJK full-width punctuation` describe.
3. `pnpm-lock.yaml`: add-only, one importer entry.
**Two-minute verification:** `pnpm --dir ui exec vitest run
packages/plugin-markdown/src/markdown-render.test.tsx`. Expect 24
passed. With the plugin removed from `remarkPlugins`, 7 of them go red,
as the ablation below shows.
## Tests
Tests: `@object-ui/plugin-markdown` `test` (6 files, 63 tests) and
`type-check` (`tsc --noEmit && tsc -p tsconfig.test.json`), plus `pnpm
--dir ui exec vitest run scripts/`, all run on the final head
`f0a46f212cf`.
New pins, as a top-level describe in the package's existing render
harness:
- `**关闭日期**和**解决耗时(小时)**会被清空` renders both runs as strong (the card's
main repro, from `crm_service_cases.zh.md`).
- `- **每个项目一张报销单。**每个项目的费用` renders strong (full-width full stop).
- `**它跳过和拒绝什么:**已经在活动中的人` renders strong (full-width colon).
- `**投资回报率(%)**是(收入 − 成本)` renders strong.
- Sanitizer: the rendered tag set is exactly `div`/`p`/`strong`. An
event-handler attribute and a `javascript:` link stay stripped inside a
CJK bold run.
- English controls, unchanged: `a **bold** word` and `foo**bar**baz` are
bold. A closer after whitespace, a code span and backslash escapes stay
literal with no `strong`.
- Composition: a CJK bold run inside a `> [!NOTE]` alert keeps the
`markdown-alert-note` callout, and one inside a GFM table cell keeps the
`table`. Both render strong.
<details><summary>Red on the base, green with the fix</summary>
Before the fix, on `62692b7f8b3` with only the test file added:
```
× a closer after a full-width parenthesis, before a CJK letter renders strong
× a closer after a full-width full stop, before a CJK letter renders strong
× a closer after a full-width colon, before a CJK letter renders strong
× a closer after a full-width parenthesis holding a percent sign renders strong
× adds no element the sanitizer did not already allow
× keeps raw HTML and javascript: links stripped inside a CJK bold run
× still renders a CJK bold run inside an alert and a GFM table
Tests 7 failed | 17 passed (24)
```
The fix, on `f0a46f212cf`:
```
> vitest run --root ../.. packages/plugin-markdown/
Test Files 6 passed (6)
Tests 63 passed (63)
> tsc --noEmit && tsc -p tsconfig.test.json
os-verify-lock: VERDICT command-exit 0
```
</details>
<details><summary>Ablation (scripts/ablation-replace.mjs, then
restored)</summary>
The test imports `./MarkdownImpl` from source, so there is no dist hop
to rebuild.
```
ablation-replace: anchor "const remarkPlugins = [remarkCjkFriendly, remarkGfm, remarkAlert]" x1 (before)
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 2e6b55a -> 860686304aa7
Tests 7 failed | 17 passed (24)
ablation-replace: command exited 1
ablation-replace: blob after restore 2e6b55a
ablation-replace: blob at HEAD 2e6b55a
ablation-replace: ok restored: blob == HEAD (2e6b55a) and `git diff HEAD` is empty
```
The same 7 go red, and the 17 controls stay green.
</details>
## Acceptance notes
- **The MCP `read_package_doc` / `search_package_docs` (card's last
line) do not render markdown.**
`packages/runtime/src/domains/mcp-package-docs.ts` returns the doc's
`content` verbatim (served locale or translation) and excerpts the raw
source for search hits. No emphasis parse runs there, so the CJK
flanking rule does not apply. The reading client parses the markdown
itself. Not changed.
- GFM strikethrough (`~~`) beside full-width punctuation is outside
`remark-cjk-friendly` by its own README, which points to a sibling
`remark-cjk-friendly-gfm-strikethrough` package. Chat has the same
scope. Not measured on any shipped manual: no reproduction, so no card.
Follow-up: none.
- `@object-ui/plugin-markdown` builds with every bare import external,
so `dist/index.js` imports `remark-cjk-friendly/parseOnly` and resolves
it through the new dependency. The console already bundles the same
version for chat.
- Local verification is scoped to the derived gate list (below). The
branch is not merged with the newer `origin/main`. `overlap-check`
reports clean merges with `origin/main` and with the three open PRs that
share a file (#36845, #35129, #34223).
## Verification
<details><summary>Derived gate families (dispatch-gates, 60 derived: 59
run, 1 NOT MEASURED, 0 UNRUN)</summary>
`node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack
--ran ran.list` gives `✓ dispatch-gates --ran: 60 derived famil(ies)
accounted for — 59 run, 1 NOT-MEASURED`. The derivation names the tree
`objectstack-ai/objectstack` at `f0a46f212cf`.
- 58 families exit 0, `pnpm --dir ui exec vitest run scripts/` among
them (`Test Files 172 passed | 2 skipped`, `Tests 5126 passed | 2
skipped`). Exit codes were captured before any pipe.
- NOT MEASURED: `pnpm check:dual-build-cjs-loads`, reason: its self-test
passes (94 cases), but the scan answers `PREREQUISITE NOT MET` (exit 3).
It reads every `@objectstack/*` package's `dist`, and this worktree
built only the plugin-markdown closure. CI `Lint & Repo Gates` runs it.
- `node scripts/pm/overlap-check.mjs` before the push: `VERDICT clean
exit 0`.
</details>
`@object-ui/plugin-chatbot` is not tested locally: its diff is a comment
only. CI `Test UI` and `Type Check UI` run it.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzhoBbwh8URjwQHde8v -->
Co-authored-by: Claude <noreply@anthropic.com>1 parent 7c9b22b commit 23d61fa
6 files changed
Lines changed: 114 additions & 1 deletion
File tree
- .changeset
- ui/packages
- plugin-chatbot/src
- plugin-markdown
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
29 | 34 | | |
30 | 35 | | |
31 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
98 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
99 | 122 | | |
100 | 123 | | |
101 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
0 commit comments