Skip to content

Prevent snake_case identifiers from being detected as LaTeX math#291

Merged
elasticsounds merged 1 commit intomainfrom
elasticsounds/latex-underscore-fix
Apr 17, 2026
Merged

Prevent snake_case identifiers from being detected as LaTeX math#291
elasticsounds merged 1 commit intomainfrom
elasticsounds/latex-underscore-fix

Conversation

@elasticsounds
Copy link
Copy Markdown
Contributor

Summary

  • Tighten UNDELIMITED_LATEX_RE and LATEX_EXPR_RE in packages/pipeline/src/package-web.ts with lookaround assertions so bare subscript/superscript atoms no longer match inside snake_case identifiers like variable_name, while X_i / X^2 continue to convert.
  • Add two regression tests in packages/pipeline/src/__tests__/package-web.test.ts: one for pure prose containing variable_name / snake_case, and one for mixed prose where variable_name must be preserved alongside a real X_i math fragment.

Test plan

  • pnpm --filter @adt/pipeline test passes, including the two new convertLatexToMathml (HTML) cases.

Tighten the bare subscript/superscript patterns in UNDELIMITED_LATEX_RE
and LATEX_EXPR_RE with lookaround assertions so identifiers like
`variable_name` are no longer matched, while expressions like `X_i` and
`X^2` still convert correctly.
@elasticsounds elasticsounds merged commit b5352b0 into main Apr 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant