Skip to content

Crash for latex inline mode. #252

@tylzh97

Description

@tylzh97

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions