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

Custom command causes AttributeError: 'NoneType' object has no attribute 'has_text' #40

Open
MayeulC opened this issue May 3, 2023 · 0 comments

Comments

@MayeulC
Copy link

MayeulC commented May 3, 2023

Hello, I use the following snippet as part of my manuscript:

% Overleaf has an outdated inkscape version, try to work around it:
% Inspired from https://tex.stackexchange.com/a/650621
\def\overleafStripPrefix#1>{}
\def\isoverleaf{FF\fi
        \def\predicate{output}%
        \edef\predicate{\expandafter\overleafStripPrefix\meaning\predicate}%
        \edef\job{\jobname}%
        \ifx\job\predicate
}

Including just that in a tex file is enough to make flap abort.

Backtrace
$ flap main.tex flaped/
FLaP 0.6.0
Traceback (most recent call last):
  File "/home/mcantan/.local/bin/flap", line 8, in <module>
    sys.exit(main())
  File "/home/mcantan/.local/lib/python3.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/mcantan/.local/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/mcantan/.local/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/mcantan/.local/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/ui.py", line 117, in main
    .run(tex_file, output)
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/ui.py", line 43, in run
    request.execute()
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/engine.py", line 84, in execute
    tokens = self._rewrite(self.read_root_tex,
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/engine.py", line 94, in _rewrite
    return parser.rewrite()
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/parser.py", line 90, in rewrite
    result += self._rewrite_one()
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/parser.py", line 98, in _rewrite_one
    return self._rewrite_command()
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/parser.py", line 114, in _rewrite_command
    return macro.rewrite(self)
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/macros/core.py", line 32, in rewrite
    self._execute(parser, invocation)
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/macros/core.py", line 43, in _execute
    self._rewritten_body = parser._spawn(body, dict()).rewrite()
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/parser.py", line 90, in rewrite
    result += self._rewrite_one()
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/parser.py", line 96, in _rewrite_one
    return self._rewrite_group()
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/parser.py", line 105, in _rewrite_group
    tokens += self._rewrite_one()
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/parser.py", line 96, in _rewrite_one
    return self._rewrite_group()
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/parser.py", line 105, in _rewrite_group
    tokens += self._rewrite_one()
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/parser.py", line 98, in _rewrite_one
    return self._rewrite_command()
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/parser.py", line 114, in _rewrite_command
    return macro.rewrite(self)
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/macros/commons.py", line 112, in rewrite
    invocation = self._parse(parser)
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/macros/commons.py", line 64, in _parse
    self._capture_arguments(parser, invocation)
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/macros/commons.py", line 80, in _capture_arguments
    value = parser._evaluate_until(
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/parser.py", line 186, in _evaluate_until
    while not is_excluded(self._next_token):
  File "/home/mcantan/.local/lib/python3.10/site-packages/flap/latex/macros/commons.py", line 81, in <lambda>
    lambda token: token.has_text(next_token._text))
AttributeError: 'NoneType' object has no attribute 'has_text'

I tried to remove that snippet, but I'm encountering another issue. I'll isolate a reproducer and open a new issue.

@MayeulC MayeulC changed the title AttributeError: 'NoneType' object has no attribute 'has_text' caused by custom command Custom command causes AttributeError: 'NoneType' object has no attribute 'has_text' May 3, 2023
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