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

xparse regex argument specifier #820

Closed
blefloch opened this issue Nov 5, 2020 · 12 comments
Closed

xparse regex argument specifier #820

blefloch opened this issue Nov 5, 2020 · 12 comments
Assignees
Labels
enhancement New feature or request l3regex xparse Historical: see latex3/latex2e

Comments

@blefloch
Copy link
Member

blefloch commented Nov 5, 2020

With the addition of \peek_regex_replace_once:nnTF to l3regex in #779, it becomes rather easy to implement an all-encompassing argument type in xparse that would cover various additions that people asked throughout the years (e.g., grabbing any number of + or * tokens, grabbing digits, or whatever). Something like

\NewDocumentCommand { \rating }
  { x{[A-Fa-f]} x{\+*|\-*} }
  { \texttt{#1}\textsuperscript{#2} }
\rating A+++
\rating F-

would print A^{+++} and F^-. Just as for other argument types there could be an argument type X with a default value for when the argument is not found.

@blefloch blefloch added xparse Historical: see latex3/latex2e enhancement New feature or request l3regex labels Nov 5, 2020
@u-fischer
Copy link
Member

But I guess that one can't do this in an expandable way, and that writing an expandable version that does something more or less sensible e.g. for such a in the bookmarks would be difficult to impossible? (That doesn't mean that one shouldn't write such commands, only that it should be documented/discussed how argument types behave in different contexts).

@josephwright
Copy link
Member

Yes, non-expandable only, but that's no different to trailing-optional or verbatim or whatever.

@eg9
Copy link
Contributor

eg9 commented Nov 5, 2020

It would be a very nice addition, indeed. I'd not worry about expandability. Parsing expandably has to use different tools anyway.

@josephwright
Copy link
Member

I've merged the expl3 support, so we should be good to go here.

@blefloch
Copy link
Member Author

blefloch commented Dec 7, 2020

In which files should new argument types be documented?

@josephwright
Copy link
Member

I think new stuff should go into usrguide3, as it will be added to the part of xparse that will move 'finally' across in the near future.

@blefloch
Copy link
Member Author

blefloch commented Dec 9, 2020 via email

@FrankMittelbach
Copy link
Member

In the latex2e repository (but probably only in master at the moment - not checked) with the next PL there (hopefully in a few of days when @PhelypeOleinik has recovered from thesis stress) it should appear in "develop" there.

@josephwright
Copy link
Member

It's in https://github.com/latex3/latex2e/tree/hotfix/gh448, which is as-yet not merged to master or to develop. (Ideally each hotfix should get merged across to develop as well as master, but I suspect we are going to bulk-merge master back to develop.)

@FrankMittelbach
Copy link
Member

given that there are always merge conflicts because of the date and version changes (and we seldom have several hotfixes at the same time) doing a bulk merge back to develop when the PL is ready seems more sensible to me.

@blefloch
Copy link
Member Author

blefloch commented Dec 9, 2020 via email

@josephwright
Copy link
Member

I've re-reported at latex3/latex2e#1065 in the 2e format and without the discussion of the underlying expl3 code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request l3regex xparse Historical: see latex3/latex2e
Projects
None yet
Development

No branches or pull requests

5 participants