Closed kdeldycke closed 1 year ago
And for those interested in the details of my implementation, I have a custom AnsiHtmlFormatter
, which inherits from Pygments.HtmlFormatter
and ExtendedColorHtmlFormatterMixin
from the pygments_ansi_color
project.
This custom formatter allow me to render ANSI codes in Sphinx code blocks. See for instance the ANSI color matrix at: https://kdeldycke.github.io/click-extra/colorize.html#colors-and-styles
And because of Furo's hard-coded reference to HtmlFormatter
, I cannot simply set PygmentsBridge.html_formatter
and expect Furo to use my custom formatter.
In the mean time, I monkey-patched Furo at: https://github.com/kdeldycke/click-extra/blob/115d6a879accf66a4ff71f81cf5693373d79aa3a/click_extra/sphinx.py#L152-L166
Thanks for those details! This seems OK. :)
Thanks @pradyunsg for the quick merge! 🎉
This patch respect the
HtmlFormatter
class set onPygmentsBridge
, instead of hard-coding it into Furo. That way Furo can use the same Pygments formatter as the whole Sphinx machinery.For the context, I encountered this issue while trying to implement a way for Pygments to render ANSI codes in documentation.