ipypublish.filters.ansi_listings module

Filters for processing ANSI colors within Jinja templates.

ipypublish.filters.ansi_listings.ansi2listings(text, escapechar='%')[source]

Convert ANSI colors to LaTeX colors.

Parameters
  • text (str) – Text containing ANSI colors to convert to LaTeX

  • escapechar (str) – escape character

Examples

>>> print(ansi2listings('Folder("subdir1")'))
%\textcolor{ansi-green}{Folder}%("subdir1")
>>> print(ansi2listings('Folder("subdir1")'))
%\textcolor{ansi-green-intense}{\textbf{Folder}}%("subdir1")
>>> print(ansi2listings('Folder("subdir1")'))
%\def\tcRGB{\textcolor[RGB]}\expandafter\tcRGB\expandafter{\detokenize{10,10,10}}{Folder}%("subdir1")