siefkenj / unified-latex

Utilities for parsing and manipulating LaTeX ASTs with the Unified.js framework
MIT License
85 stars 20 forks source link

url + href verbatim arguments #70

Closed retorquere closed 7 months ago

retorquere commented 7 months ago

Could you add some tests for these macros?

Where? The unified-latex-util-pegjs package doesn't seem to have any tests.

siefkenj commented 7 months ago

I think this is the wrong approach, actually. It appears \url does not take a verbatim argument. Go ahead and run:

\documentclass{article}
\usepackage{hyperref}

\newcommand{\foo}{FOO}

\begin{document}

\foo

\url{hi~there\foo}

\end{document}

and observe that \foo gets expanded.

retorquere commented 7 months ago

You're right... but then I don't know what kind of environment they are, because \url{#} compiles without an error to show an #.

siefkenj commented 7 months ago

\url redefines the control codes of several characters so they parse as regular strings. But, I don't understand the issue. You shouldn't be getting any errors when parsing with unified-latex.

retorquere commented 7 months ago

I'm still working my way through understanding how unified-latex hangs together, sorry -- I opened this issue based on my reading of the code, and I didn't test properly.

retorquere commented 6 months ago

\url redefines the control codes of several characters so they parse as regular strings

But this should then still be accomodated. How do I go about this?

siefkenj commented 6 months ago

If you want the URL as a string, you can call toString(...) on the argument.