SIGN IN SIGN UP

fix(documents): don't treat intraword underscores as emphasis (#10)

CommonMark allows intraword emphasis with `*` but not with `_`, because
underscores are load-bearing inside ordinary words. `parseInlineMarkdown`
applied no such rule, and the damage isn't a stray italic — the underscores
are CONSUMED as delimiters, so the characters are gone from the stored
document:

  "call user_id and order_id now"
    -> "call user" + italic("id and order") + "id now"
  "see https://x.com/a_b_c now"
    -> "see https://x.com/a" + italic("b") + "c now"

Any snake_case identifier pair or underscore-bearing URL an agent writes into
a shared doc is silently corrupted, and a broken link is not something the
reader can recover by hand.

Restrict `_`/`__` to word boundaries, looking past the whole delimiter run so
`foo__bar__baz` is judged by the `o` rather than by a sibling underscore, and
skipping closers that sit inside a word — which is what still lets `_a_b_`
italicize `a_b` the way CommonMark does. `*`/`**` are untouched, so intraword
`foo*bar*baz` keeps working.
X
Xialie Zhuang committed
2e4254005e01ed62bf006bdedb8f64b390e2d4f6
Parent: ec6976b
Committed by GitHub <noreply@github.com> on 8/19/2026, 5:31:37 AM