← Back to Pull requests

[lexical-mdast] Bug Fix: Emphasis typed inside a word of any script stays as typed #9999

Closed
unknown closed this pull request without merging on Dec 04, 2026 08:56 UTC
View on GitHub
unknown unknown commented on Nov 30, 2026 22:59 UTC
Author

Description

Since #9920, typing xy keeps it as typed, because a or ~ run inside a word is more often math or a name. But only ASCII letters and digits counted as inside a word, so caféx, словокурсив and λέξηπλάγια still converted mid-word.

A letter or decimal digit of any script now counts, with any combining marks after it, so caféx stays as typed, and so does cafe\u0301x, an e with a combining acute (U+0301). The exceptions, where there is no word boundary to wait for, are unchanged: the CJK of the CJK-friendly amendment (isCjkCharacter, which also covers Hangul), and the scripts Unicode breaks into words by dictionary (Line_Break=SA): Thai, Lao, Khmer, Myanmar, Tai Le, New Tai Lue, Tai Tham, Tai Viet and Ahom. There, emphasis still converts after a letter (日本語, ภาษาไทยเอียง). A symbol is not inside a word: a character an emoji presentation selector (U+FE0F) or a keycap (an enclosing mark) follows, or an ideograph with an ideographic variation selector, so ❤️x, 1️⃣x and 葛󠄀強調 still convert. Markdown import and export are untouched.

This supersedes the two earlier descriptions on the PR. Two later commits take the automated review's remaining points:

  • A number that is not a decimal digit, such as ① or ½, is not a word character ([\p{L}\p{Nd}], the any-script form of [A-Za-z0-9], rather than [\p{L}\p{N}]). ① is not in isCjkCharacter, so 手順①注意 converted after the second commit where main converts it; it converts again.

  • The scripts written without spaces are matched by their script (\p{sc=…}) rather than their script extensions (\p{scx=…}), which also take in letters other scripts share, such as U+02BC, the apostrophe Ukrainian writes inside a word. So обʼєкт now stays as typed, as after any other letter.
  • Changeset

    .changeset/mdast-typed-emphasis-any-script.md (@lexical/mdast patch, [fix], with a Verify: paragraph).

    Test plan

    Before

    MdastStream.ts as on main (4aa11ac91a47), with this branch's tests:

    ./node_modules/.bin/vitest --project unit --no-watch -t "closing delimiter after|still applies emphasis" packages/lexical-mdast/src/__tests__/unit/MdastShortcuts.test.ts
    

    7 of the 34 selected cases fail: caféx, словокурсив, λέξηπλάγια, caféx, café~~x~~, cafe\u0301x (U+0301) and обʼєкт* (U+02BC). The symbol, CJK, Line_Break=SA, ① and ½ cases pass on main and guard against regressions.

     Test Files  1 failed (1)
          Tests  7 failed | 27 passed | 64 skipped (98)
    

    After

    The same command on this branch:

     Test Files  1 passed (1)
          Tests  34 passed | 64 skipped (98)
    

    The full unit suite (pnpm run test-unit, run at two workers):

     Test Files  1041 passed | 6 skipped (1047)
          Tests  41131 passed | 423 expected fail | 174 skipped (41728)
    

    pnpm run ci-check exits 0 (TypeScript, Flow Found 0 errors, Prettier, ESLint, and the changeset check all pass). The branch is merged up to date with main (c302b4bb4bf8); main's #10001 fixes the playground DateTimeComponent date-picker tests that fail in December, which were the only failures in the core-tests / unit (24.x) run.

    Not run: the browser-mode tests (pnpm run test-browser) and the e2e suites. The change is in the shortcut scanner, which the unit tests above drive by typing into an editor.

    🤖 Generated with Claude Code

    Diff: 430 lines (+322 / -108) across 5 files Reviewer: potatowagon Review duration: 4916m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 430 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.363
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #9999"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.1% (MEDIUM) · Higher = larger blast radius
    45.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.8% · Safe to merge
    17.8%
    Repository