Closed mojaie closed 7 months ago
Hi @mojaie !
Wouldn't this be a bug in the type you are printing? I think it would not be a good move to render as text/plain
since we are printing to HTML. We try first to render it using HTML, if it is not possible, we ask for the default one. I think we would break other types if we modify this behavior.
Thank you very much.
SimpleGraph
in Graphs.jl does not have show(io::IO, MIME"text/html", x). `show(io::IO, m::MIME"text/html", mol::SimpleMolGraph) in MolecularGraph.jl generates a div element including SVG of chemical structure drawing so that Pluto and Jupyter can easily display it.
On the other hand, someone may prefer compact table view with summarized text in some cases.
So, my question may be which method should package developers implement to display good summary or visualization of API data types.
Hi @mojaie !
Sorry for the delay. In this case, you can always use a formatter to adjust the display only within PrettyTables.jl. Would it work?
Yes, formatter works. Thank you very much.
So, providing Base.show(io::IO, ::MIME"text/html")
that returns this formatted table seems to be a solution.
Perfect! Thanks for the info! :)
User-defined type does not always implement default show MIME types, so these data types can generate verbose output in table cells.
A workaround is to provide a default show method, but I'm not sure if it is a good practice.
How about calling user-defined
show(io::IO, MIME"text/plain", x)
instead of defaultshow(io::IO, x)
, if defined?https://github.com/ronisbr/PrettyTables.jl/blob/3d614c9294a6477a5f7cf09bdcacd4d50fd69d68/src/backends/html/parse_cell.jl#L91-L102