You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to pretty print in various formats such as colored strings (fansi.Str), HTML and LaTeX. It would be ideal if there is an API available that allows me to reuse existing pretty print logic while only needing to customize the output formatting.
The text was updated successfully, but these errors were encountered:
As you note, the library is designed to output text. It's not in the spirit of the approach to change the library to output different forms of text (HTML etc).
In projects where I have wanted to output "the same thing" in multiple text formats (say, JSON, XML, HTML, etc) I have done it by making an interface that takes the things I want to pretty-print. Then multiple implementations of that interface define pretty-printers for the different textual formats that I want. Then I can switch formats by just choosing which pretty-printer implementation I use.
In my experience, this is a good way to do it since you get to control the formatting of the different formats using the high-level pretty-printing constructs (eg laying out JSON is different to laying out HTML). You want to have control of that at the high level, not at the low level of the output text.
I would like to pretty print in various formats such as colored strings (fansi.Str), HTML and LaTeX. It would be ideal if there is an API available that allows me to reuse existing pretty print logic while only needing to customize the output formatting.
The text was updated successfully, but these errors were encountered: