@c4a/context-cli 0.7.84 → 0.7.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli.js CHANGED
@@ -87359,6 +87359,30 @@ var init_packageSiteTheme = __esm(() => {
87359
87359
  state.md.options.html = /^(?:_site|custom)\//.test(state.env.relativePath || '');
87360
87360
  });
87361
87361
  md.block.ruler.disable('snippet');
87362
+ // CommonMark only closes **bold** after punctuation when whitespace or
87363
+ // punctuation follows, so Chinese such as **用 MCP?**在 stays literal.
87364
+ // A CJK letter on the outer side counts like whitespace; other runs keep
87365
+ // the standard result.
87366
+ const cjkLetter = /[\p{sc=Han}\p{sc=Hiragana}\p{sc=Katakana}\p{sc=Hangul}]/u;
87367
+ const InlineState = md.inline.State;
87368
+ md.inline.State = class extends InlineState {
87369
+ scanDelims(start, canSplitWord) {
87370
+ const scanned = super.scanDelims(start, canSplitWord);
87371
+ const end = start + scanned.length;
87372
+ // Whole code points, so extension-plane Han counts too.
87373
+ const before = Array.from(this.src.slice(Math.max(0, start - 2), start)).pop() ?? ' ';
87374
+ const after = Array.from(this.src.slice(end, Math.min(end + 2, this.posMax)))[0] ?? ' ';
87375
+ const lastCjk = cjkLetter.test(before), nextCjk = cjkLetter.test(after);
87376
+ if (!lastCjk && !nextCjk) return scanned;
87377
+ const { isMdAsciiPunct, isPunctChar, isWhiteSpace } = md.utils;
87378
+ const lastCode = before.codePointAt(0), nextCode = after.codePointAt(0);
87379
+ const lastPunct = isMdAsciiPunct(lastCode) || isPunctChar(before), nextPunct = isMdAsciiPunct(nextCode) || isPunctChar(after);
87380
+ const lastSpace = isWhiteSpace(lastCode), nextSpace = isWhiteSpace(nextCode);
87381
+ const left = !nextSpace && (!nextPunct || lastSpace || lastPunct || lastCjk);
87382
+ const right = !lastSpace && (!lastPunct || nextSpace || nextPunct || nextCjk);
87383
+ return { ...scanned, can_open: left && (canSplitWord || !right || lastPunct), can_close: right && (canSplitWord || !left || nextPunct) };
87384
+ }
87385
+ };
87362
87386
  const linkOpen = md.renderer.rules.link_open;
87363
87387
  md.renderer.rules.link_open = (tokens, index, options, env, self) => {
87364
87388
  // Let VitePress normalize the base and .md URL before adding a target;