ansi2html is a Python library that converts text containing ANSI escape codes (commonly used for colored terminal output) into HTML or LaTeX markup. It is currently at version 1.9.2 and maintains an active development cycle with regular updates addressing features and minor bug fixes.
pip install ansi2htmlVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to convert a string with ANSI color codes into an HTML fragment for embedding, or a complete HTML document with styling.
Always specify `full=False` (e.g., `converter.convert(ansi_text, full=False)`) if you intend to embed the output into another HTML structure. Only use `full=True` if you're generating a standalone HTML file.
For `full=False` output, ensure you provide your own CSS to define the `ansi-*` classes. You can copy the default styles from the library's source or create custom ones. For `full=True`, styles are automatically included.
Add the import statement `from ansi2html import Ansi2HTMLConverter` at the top of your Python file.
Use the direct import `from ansi2html import Ansi2HTMLConverter`. If your script file is named `ansi2html.py`, rename it to something else (e.g., `my_script.py`) to avoid conflicting with the library's module name.
No dependency data recorded yet.