typst: fix CodeIdent vs "_" token overlap after #keyword CallExpr?
Build and Deploy Verso / deploy (push) Failing after 8m41s

KeywordExpr { CodeKeyword CallExpr? } merges the post-keyword LR state
with document-level markup states, where "_" opens Emphasis.  CodeIdent
starts with identHead which includes "_", so the two tokens overlap.

Adding "_" after CodeIdent in @precedence resolves the conflict: CodeIdent
wins in the merged state (correct for '#set _name(...)'), and in pure markup
states CodeIdent is not in the valid set so "_" still opens Emphasis.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
claude
2026-06-08 09:16:35 +00:00
parent b16b096744
commit 7a5218d472
@@ -222,7 +222,11 @@ Escape { "\\" EscapeChar }
// "(" > "." > "]" > text tokens: after '#' CodeIdent, callSuffix delimiters // "(" > "." > "]" > text tokens: after '#' CodeIdent, callSuffix delimiters
// must win over MarkupContent/StrongText/EmphText in merged states. // must win over MarkupContent/StrongText/EmphText in merged states.
// LineCommentContent and MathContent are external tokens — not listed here. // LineCommentContent and MathContent are external tokens — not listed here.
@precedence { CodeKeyword CodeBool CodeIdent EscapeChar "(" "." "]" spaces MarkupContent StrongText EmphText } // "_" added after CodeIdent: KeywordExpr { CodeKeyword CallExpr? } merges
// the post-keyword state with markup states where "_" starts Emphasis.
// CodeIdent wins so '#set _name(...)' is tokenised correctly; in pure markup
// states CodeIdent is not in the valid set so "_" still opens Emphasis.
@precedence { CodeKeyword CodeBool CodeIdent EscapeChar "(" "." "]" "_" spaces MarkupContent StrongText EmphText }
} }
@skip { spaces } @skip { spaces }