Skip to content

fix(plugin-markdown): bold ending in full-width punctuation renders bold before a CJK letter - #36968

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/issue-36946-manual-reader-cjk-bold
Nov 24, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/issue-36946-manual-reader-cjk-bold

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

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.
Red on the base, green with the fix

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
Ablation (scripts/ablation-replace.mjs, then restored)

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 2e6b55acc36f -> 860686304aa7
      Tests  7 failed | 17 passed (24)
ablation-replace: command exited 1
ablation-replace:   blob after restore  2e6b55acc36f25b252ca4bbd3501824cf5c39c0c
ablation-replace:   blob at HEAD        2e6b55acc36f25b252ca4bbd3501824cf5c39c0c
ablation-replace: ok restored: blob == HEAD (2e6b55acc36f) and `git diff HEAD` is empty

The same 7 go red, and the 17 controls stay green.

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 (fix(runtime,service-print,console): the print door answers on a hosted kernel, and an absent service reads as a localized line #36845, chore: version packages #35129, fix(settings)!: offer the knowledge settings only where the knowledge service is mounted #34223).

Verification

Derived gate families (dispatch-gates, 60 derived: 59 run, 1 NOT MEASURED, 0 UNRUN)

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.

@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

…old before a CJK letter

The manual reader renders package docs through MarkdownImpl, whose remark
chain ran remark-gfm and remark-github-blockquote-alert only. A closing
`**` with full-width punctuation before it and a CJK letter after it is
not right-flanking under CommonMark, so the run stayed literal asterisks.

Run remark-cjk-friendly/parseOnly first in the chain, the rule the chat
surface already runs, and cross-reference the two import sites (neither
package depends on the other).

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzhoBbwh8URjwQHde8v
@github-actions github-actions Bot added size/m dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 24, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzesUz1Y8VZuKJRhVL8

席位核对 — ACCEPT · repo:objectstack#3 · head f0a46f2 · 2026-11-24T12:08Z

L1 read of #36968 (card #36946, p1) at f0a46f212cf10cc48287d4e582685b1e5a1dd189. Clause-② no and Metadata-protocol none, both true: this is a render-pipeline change with no props, exports or accept set touched. NOT governed, 115 changed lines, no contract review owed. l1-face is clean.

Against the card. The manual reader (ui/apps/console/src/pages/DocPage.tsx) renders through @object-ui/plugin-markdown's MarkdownRenderer (import at line 13, use at line 452). MarkdownImpl.tsx now runs [remarkCjkFriendly (parseOnly), remarkGfm, remarkAlert]. That is the rule chat already runs from chatMarkdownPlugins.ts: the same package, the same ^2.3.4, the same parseOnly entry, ordered ahead of gfm so it owns the attention tokenizer. The card's three shapes (**…(…)** + CJK, **…。** + CJK, **…:** + CJK) are pinned and red on the base (7 failed). The ablation is red again (7), then restored.

Controls. ASCII emphasis, code spans, backslash escapes, an alert and a GFM table all render as before. Tag names stay inside the sanitize schema (div, p, strong). Raw HTML and javascript: links are still stripped inside a CJK bold run. Shared plugin list: the card asked for one "ideally", and the dev kept two copies with cross-referencing comments, because neither package depends on the other and the config shapes differ (a streamdown CjkPlugin vs react-markdown remarkPlugins). That is a reasoned call, and I accept it.

Reach beyond the card. MarkdownRenderer also draws Settings info banners (SettingsField.tsx). The same rule applies there, and it can only turn literal asterisks into the bold the author wrote. MCP read_package_doc / search_package_docs return raw markdown and render nothing, so they are correctly out of scope, which answers the card's open question.

Dependency and changeset. remark-cjk-friendly sits in dependencies, and the lockfile adds +3 lines resolving to the version chat already locks, with no new snapshot. The changeset names @object-ui/plugin-markdown (patch) and @object-ui/plugin-chatbot (patch, a comment-only change). Naming the comment-only package is harmless, and each sentence holds.

Nits.

  • N1. ~~strikethrough~~ beside full-width punctuation needs the sibling plugin (remark-cjk-friendly-gfm-strikethrough). No shipped manual uses it. The dev noted it and did not file it, which is fine at this size.
  • N2. The branch is not merged with newer main. overlap-check is clean against main and the three open lockfile PRs, so the queue's merge settles it.

Mechanical. All-checks: 49 success · 10 expected skips · 0 failed · 0 pending. Floor checks are green, mergeable_state is clean, and Fixes #36946 delivers the card.

Every open finding is a nit. ACCEPT, ordinary queue landing.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzhoBbwh8URjwQHde8v

Landing · 2026-11-24T12:09Z · area ux-B · head f0a46f212cf10cc48287d4e582685b1e5a1dd189

  • L1: ACCEPT 7131020058 (L1-a, on this head). Only optional nits remain: N1, GFM strikethrough beside full-width punctuation needs the sibling plugin, and no shipped manual uses it; N2, the branch is not merged with newer main, which the queue merge settles. Neither has a user-visible defect.
  • Contract review: none owed (Clause-② no, Metadata-protocol none).
  • check-governed-merges.mjs --pr 36968: NOT governed, 115 changed lines; this card's only PR.
  • landing-k.mjs --pr 36968: OK, K = 1 < 15.
  • Checks on this head: 49 success / 10 skipped / 0 failing; mergeable_state clean.
  • Action: ready for review + auto-merge through the merge queue.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 24, 2026 12:09
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 23d61fa Nov 24, 2026
60 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-36946-manual-reader-cjk-bold branch November 24, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Manual reader: bold ending in full-width punctuation renders as literal asterisks before a CJK letter (#33723 fixed chat only)

2 participants