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

feat: ignore \\text command #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

edeustace
Copy link
Contributor

We have LaTex that intersperses text into mathematical expressions. We
want to be able to parse the LaTeX to math and just ignore thes
commands. This commit adds text as a whitespace rule.

I'm new to this lib so this may be a fairly naive approach - happy for feedback.

We have LaTex that intersperses text into mathematical expressions. We
want to be able to parse the LaTeX to math and just ignore thes
commands. This commit adds text as a whitespace rule.
@dqnykamp
Copy link
Member

Do you have any ideas how to modify the regular expression to match all of "\text{multiple {words} here}"? One probably would not encounter that frequently, but I did notice that it would stop at the first "}" in the above example. I'm wondering if one might need to actually parse the \text to match the braces.

@kisonecat, any opinion on dealing with the case of braces within the \text?

@edeustace
Copy link
Contributor Author

any further thoughts on this @dqnykamp ?

@dqnykamp
Copy link
Member

I played around with the idea of having \text{} be parsed as a regular command (with special logic so that its contents aren't parsed as math), but I couldn't come up with a satisfactory solution on how to handle the resulting \text{} object. For example, a common use of \text{} is to make sub/superscripts words. How should "a_\text{long} b" be handled? We couldn't ignore the \text{} in that case; one would need to put something in for the subscript. I would probably want the result to be ['*', ['_', 'a', 'long'], 'b']. Once we go down that road, we start departing from your idea to make \text{} be like a \comment{} command, so I didn't pursue that idea further.

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.

2 participants