Skip to content

fix: repeated verbatim arguments using depth#132

Open
robmcl4 wants to merge 1 commit into
phfaist:mainfrom
robmcl4:main
Open

fix: repeated verbatim arguments using depth#132
robmcl4 wants to merge 1 commit into
phfaist:mainfrom
robmcl4:main

Conversation

@robmcl4

@robmcl4 robmcl4 commented Mar 27, 2026

Copy link
Copy Markdown

Fixes an issue related to verbatim formatted arguments failing to parse. Consider documents which define a macro which accepts a verbatim argument, for example \my_macro{..}. The macro may accept embedded {} blocks, for example: \my_macro{foo{bar}}. This is valid LaTeX and the argument should be parsed literally as 'foo{bar}'.

The issue arises because the verbatim parser tracks depth via an instance variable depth_counter. It is initialized to depth_counter = 1. However, after parsing the first verbatim argument it decreases to 0, then after the following it decreases again to -1, etc.

This causes early termination of parsing in subsequent verbatim parses which make meaningful use of the depth counter, and the remainder of the document will fail to parse correctly.

For example, the following would fail to parse correctly: \my_macro{foo} \my_macro{bar{}}.

The fix is to reset the depth counter to 1 whenever the parsing procedure begins.

Fixes an issue related to `verbatim` formatted arguments
failing to parse. Consider documents which define a macro
which accepts a verbatim argument, for example \my_macro{..}.
The macro may accept embedded {} blocks, for example:
\my_macro{foo{bar}}. This is valid LaTeX and the argument
should be parsed literally as 'foo{bar}'.

The issue arises because the verbatim parser tracks depth
via an instance variable `depth_counter`. It is initialized
to `depth_counter = 1`. However, after parsing the first
verbatim argument it decreases to `0`, then after the following
it decreases again to `-1`, etc.

This causes early termination of parsing in subsequent verbatim parses
which make meaningful use of the depth counter, and the
remainder of the document will fail to parse correctly.

For example, the following would fail to parse correctly:
`\my_macro{foo} \my_macro{bar{}}`.

The fix is to reset the depth counter to `1` whenever the
parsing procedure begins.
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