Repository navigation
fix(ui): render bold CJK text that ends in punctuation - #376
Merged
Merged
Conversation
CommonMark only closes `**` before whitespace or punctuation, so `**注意:**请先备份数据。` stayed as literal asterisks in Preview. Use markdown-it-cjk-friendly in both Markdown output parsers.
|
@b84330808 is attempting to deploy a commit to the linshenkx's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Preview leaves
**as literal asterisks when the bold text ends in CJK punctuation and the next character is a CJK letter, e.g.**注意:**请先备份数据。,1. **角色定位:**你是一名资深产品经理or**「重点」**内容. CommonMark only closes emphasis before whitespace or punctuation, and Chinese and Japanese text has no spaces between words.Both parsers in
prepareMarkdownOutputare affected, so this shows up in Preview (the default output view) for optimized prompts, test results and favorites.Add
markdown-it-cjk-friendly(MIT, one dependency:get-east-asian-width) to both parsers. Emphasis that CommonMark already accepts renders the same as before.Validation
tests/unit/utils/markdown-output.spec.ts: ondevelopat82e94e8the CJK cases fail for both parsers (2 failed, 1 passed); with the change all 3 pass.pnpm -F @prompt-optimizer/core build, then inpackages/ui: the Markdown and HTML preview specs (MarkdownRenderer.*.spec.ts,html-preview.spec.ts,markdown-output-client.spec.ts, 57 tests) pass,vue-tsc --noEmit,eslint src/utils/markdown-output.tsandvite buildpass.node scripts/check-no-chinese-runtime.mjspasses.