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

missing spec for \href{}{} in latexwalker #58

Open
gamboz opened this issue Mar 9, 2021 · 4 comments
Open

missing spec for \href{}{} in latexwalker #58

gamboz opened this issue Mar 9, 2021 · 4 comments

Comments

@gamboz
Copy link

gamboz commented Mar 9, 2021

I think the spec for the macro \href might be missing from pylatexenc/latexwalker/_defaultspecs.py
The following code gives error: it expects a node with two arguments, but gets a node with empty argnlist.

from pylatexenc.latex2text import LatexNodes2Text
latex = r"\href{a}{b}"
print(LatexNodes2Text().latex_to_text(latex))
@phfaist
Copy link
Owner

phfaist commented Mar 11, 2021

Thanks for reporting this. In LaTeX, the URL-related commands (like \href, \url, and \email) parse their URL argument in a special fashion to deactivate any special characters (such as $, _ or ^). So to implement them in pylatexenc requires a little more work to ensure that the URL argument is always parsed verbatim. I'm pretty busy at the moment but I'll try to find some time soon to implement them.

@gamboz
Copy link
Author

gamboz commented Mar 15, 2021

[ suggestion, please feel free to ignore :) ]
If you can change the parsing procedure based on the macro name, it might be a good idea also to ignore the second argument of \newcommands & co. As you know, these macro sometimes include the beginning or end of an environment, and the parser gets confused (as in \newcommand{\beq}{\begin{equation}}).

@phfaist
Copy link
Owner

phfaist commented Mar 15, 2021

Yes, I'm planning to improve the parsing of \newcommand instructions, too :)

@xsank
Copy link

xsank commented Apr 2, 2024

Yes, I'm planning to improve the parsing of \newcommand instructions, too :)

looking forward to this...

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

No branches or pull requests

3 participants