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

\verb not parsed correctly #127

Open
vanatteveldt opened this issue Jan 10, 2021 · 0 comments
Open

\verb not parsed correctly #127

vanatteveldt opened this issue Jan 10, 2021 · 0 comments

Comments

@vanatteveldt
Copy link

Latex \verb allows inline verbatim using a custom delimiter, e.g. \verb+code+ renders the word code as a verbatim. TexSoup does not seem to deal with this, seeing the whole argument as part of the next text node:

>>> TexSoup.TexSoup("A \\verb+code+ example").all
[A , \verb, |literal| example]
>>> TexSoup.TexSoup("A \\verb|literal| example").all[1].name
'verb'
>>> TexSoup.TexSoup("A \\verb|literal| example").all[1].args
[]
>>> TexSoup.TexSoup("A \\verb|literal| example").all[2].text
['|literal| example']

It also tries to parse the contents of the verbatim, causing an error if it contains e.g. a dollar sign:

>>> list(TexSoup.TexSoup("A \\verb|df$col| column").all)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/wva/texhtml/env/lib/python3.8/site-packages/TexSoup/__init__.py", line 87, in TexSoup
    parsed, src = read(tex_code, skip_envs=skip_envs, tolerance=tolerance)
  File "/home/wva/texhtml/env/lib/python3.8/site-packages/TexSoup/tex.py", line 22, in read
    return TexEnv('[tex]', begin='', end='', contents=buf), tex
  File "/home/wva/texhtml/env/lib/python3.8/site-packages/TexSoup/data.py", line 892, in __init__
    super().__init__(name, contents, args, preserve_whitespace, position)
  File "/home/wva/texhtml/env/lib/python3.8/site-packages/TexSoup/data.py", line 641, in __init__
    self._contents = list(contents) or []
  File "/home/wva/texhtml/env/lib/python3.8/site-packages/TexSoup/reader.py", line 49, in read_tex
    yield read_expr(buf,
  File "/home/wva/texhtml/env/lib/python3.8/site-packages/TexSoup/reader.py", line 93, in read_expr
    return read_math_env(src, expr, tolerance=tolerance)
  File "/home/wva/texhtml/env/lib/python3.8/site-packages/TexSoup/reader.py", line 212, in read_math_env
    unclosed_env_handler(src, expr, src.peek())
  File "/home/wva/texhtml/env/lib/python3.8/site-packages/TexSoup/reader.py", line 186, in unclosed_env_handler
    raise EOFError('[Line: %d, Offset: %d] "%s" env expecting %s. %s' % (
EOFError: [Line: 0, Offset: 6] "$" env expecting $. Reached end of file.
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

1 participant