Restore LaTeX alignment catcode for escaped math by jnohclee-rgb · Pull Request #3397 · pygments/pygments · GitHub
Skip to content

Restore LaTeX alignment catcode for escaped math - #3397

Open
jnohclee-rgb wants to merge 1 commit into
pygments:masterfrom
jnohclee-rgb:dharma-latex-alignment-catcode
Open

jnohclee-rgb wants to merge 1 commit into
pygments:masterfrom
jnohclee-rgb:dharma-latex-alignment-catcode

Conversation

@jnohclee-rgb

Copy link
Copy Markdown

Escaped LaTeX math retains & as an ordinary character, so matrix columns do not align. Restore its alignment catcode alongside the existing dollar, caret and underscore settings when mathescape, texcomments or escapeinside is enabled. Ordinary code ampersands keep their existing escaping.

Related to #1988.

Validation:

  • Added regression cases for all three escape options and ordinary code; the three escape cases fail before the fix.
  • tox -e py -- -W error: 5,334 passed, 16 skipped. tox -e check: passed.
  • Independently reviewed and tested. Actual generated mathescape output with amsmath compiled using the desktop editor's XeTeX/Tectonic compiler: a numeric ampersand-catcode assertion fails on the baseline and passes with this change. The existing command-line LaTeX test remains skipped because the latex executable is unavailable.

Prepared with AI assistance and independently reviewed.

Dharma — leave the code kinder than we found it.

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