You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(tostring): respect CommonMark flanking for word-attached emphasis (#506)
`tostring()` computes the on-screen width of inline markdown, used to size
table columns. Its `*`/`**` rules were gated by an `at_valid` guard that only
accepts emphasis at the start of the string or after whitespace, so word-
attached markers such as `I**'ll finish**` or `x**bold**` were treated as
literal text. The treesitter renderer, however, conceals those markers per
CommonMark's left/right-flanking delimiter rules, so the computed width was
larger than what is drawn and table borders drifted to the right.
Replace the `at_valid` guard for `*` emphasis with proper left/right-flanking
predicates that mirror treesitter's decision. Underscore (`_`) keeps the
`at_valid` guard, since CommonMark forbids intra-word `_` emphasis
(e.g. `snake_case`) which that guard already approximates.
Add test/tostring_word_attached_emphasis.md, a visual fixture (matching
test/tostring_recursion.md) whose table borders only line up with this fix.
0 commit comments