Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore style in Containers_pp #456

Open
grayswandyr opened this issue Jul 29, 2024 · 2 comments
Open

Ignore style in Containers_pp #456

grayswandyr opened this issue Jul 29, 2024 · 2 comments

Comments

@grayswandyr
Copy link
Contributor

Following up from this discussion on Discuss: I'd like to have a way to avoid outputting style formatting in some circumstances (e.g. it seems Utop doesn't like styles when using `#install_printer#).

Although it would be less efficient, I tend to think the separation between document building and document printing speaks for providing a conditional printing function, akin to CCFormat.fprintf_dyn_color. What do you think?

Regarding how to implement this, I'm not sure to understand exactly how printing works in Containers_pp but it seems that the idea would be to ignore the color/styles extension when in a Wrap constructor when printing...?

@c-cube
Copy link
Owner

c-cube commented Jul 29, 2024

It's a bit tricky as things are right now, because extensions are responsible for their own printing. So, the color extension is the only thing aware of how colors are printed. I'm not sure how to transmit the information between the call to Containers_pp.pp out doc and the internal calls to Term_color's extension pre and post callbacks (bottom of containers_pp.ml).

Maybe a simple option would be to have an optional disabled_ext:string list -> … parameter to the printing functions. This doesn't break existing code (optional) but it'd modify the printers in Pretty to just skip the Wrap constructor when the extension's name is in the disabled list. (We would only print the inner document as is). What do you think?

@grayswandyr
Copy link
Contributor Author

I like that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants