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

Crash for latex inline mode. #252

Open
tylzh97 opened this issue Jan 15, 2025 · 0 comments
Open

Crash for latex inline mode. #252

tylzh97 opened this issue Jan 15, 2025 · 0 comments

Comments

@tylzh97
Copy link

tylzh97 commented Jan 15, 2025

The input file as following:
id_000007.txt

run with command:

$ cat id_000007.txt | ansi2html --latex --inline

crash with the error:

$ cat output/crashes/id:000007* | ansi2html --latex --inline
Traceback (most recent call last):
  File "/home/xxx/Workspace/.venv/bin/ansi2html", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/xxx/Workspace/.venv/lib/python3.11/site-packages/ansi2html/converter.py", line 815, in main
    output = conv.convert(
             ^^^^^^^^^^^^^
  File "/home/xxx/Workspace/.venv/lib/python3.11/site-packages/ansi2html/converter.py", line 627, in convert
    attrs = self.prepare(ansi, ensure_trailing_newline=ensure_trailing_newline)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/Workspace/.venv/lib/python3.11/site-packages/ansi2html/converter.py", line 604, in prepare
    body, styles = self.apply_regex(ansi)
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/Workspace/.venv/lib/python3.11/site-packages/ansi2html/converter.py", line 353, in apply_regex
    no_cursor_parts = self._collapse_cursor(all_parts)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/Workspace/.venv/lib/python3.11/site-packages/ansi2html/converter.py", line 574, in _collapse_cursor
    for part in parts:
  File "/home/xxx/Workspace/.venv/lib/python3.11/site-packages/ansi2html/converter.py", line 430, in _apply_regex
    yield from self._handle_ansi_code(part, styles_used, state)
  File "/home/xxx/Workspace/.venv/lib/python3.11/site-packages/ansi2html/converter.py", line 547, in _handle_ansi_code
    style = [
            ^
  File "/home/xxx/Workspace/.venv/lib/python3.11/site-packages/ansi2html/converter.py", line 550, in <listcomp>
    if self.styles[klass].kwl[0][0] == "color"
       ~~~~~~~~~~~^^^^^^^
KeyError: 'ansi38'

Tasks

Preview Give feedback
No tasks being tracked yet.
tylzh97 added a commit to tylzh97/ansi2html that referenced this issue Jan 15, 2025
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