Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize argument parsing for vimtex#cmd#get functions #2197

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lervag
Copy link
Owner

@lervag lervag commented Oct 7, 2021

vimtex#cmd#get*() is a family of commands to parse a LaTeX command. The parser is generic and greedy, and it does not guarantee that it parses the "right amount". As it stands, the matching is not good enough, because it is restricted to the following pattern \cmd[...]*{...}*.

This PR changes the parsing to allow the following pattern: \cmd\([...]\|{...}\|(...)\|<...>\)*. This will for instance allow commands such as \begin{textblock*}{3in}[0,0](3in,1in) to be parsed as a single command with 4 different types of arguments. Also, it will allow to parse constructs such as \test{arg}[opt].

Further, the current matching only "gobbles" the arguments when they follow directly. That is, there is no tolerance for white space or "commented new lines". That is, the following LaTeX snippets are equivalent, but only the first of them is currently properly parsed:

\begin{textblock*}{3in}[0,0](3in,1in)

\begin{textblock*}{3in}[0,0]%
    %
    %
    (3in,1in)%

It could be of interest to also relax the current "no whitespace" restriction.

Opinions? @clason @reportaman

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.

None yet

1 participant