ronisbr / PrettyTables.jl

Print data in formatted tables.
MIT License
404 stars 38 forks source link

Display SVG images in the table #225

Closed mojaie closed 10 months ago

mojaie commented 11 months ago

Thank you very much for your great effort for maintaining this library.

I'm working on displaying DataFrames with SVG images in Jupyter. DataFrames seems not allow HTML inside cell, and I found a workaround of using markdown cells. Is this a intended behavior?

スクリーンショット 2023-11-11 10 19 07
mojaie commented 10 months ago

Perhaps this is more straightforward but but I wonder what the line break at the end is

スクリーンショット 2023-11-12 9 51 46
ronisbr commented 10 months ago

Hi @mojaie !

DataFrames seems not allow HTML inside cell, and I found a workaround of using markdown cells. Is this an intended behavior?

Yes, it is! The purpose is to avoid breaking the table with HTML tags. Hence, we escape everything unless you explicitly say you want those tags. You have two options. The first is the one you found by setting allow_html_in_cells, the other is to wrap the cell content into a HtmlCell as stated here: https://ronisbr.github.io/PrettyTables.jl/stable/man/html_backend/

Perhaps this is more straightforward but but I wonder what the line break at the end is

I have no ideia. Something is adding a break-line character when rendering the content. Can you please pass the option linebreaks = true?

mojaie commented 10 months ago

linebreaks = true did not work because my HTML code have SVG inside.

スクリーンショット 2023-11-16 14 52 39

HtmlCell also produced the same output as shown in the allow_html_in_cells example above. I found the HTML content have SVG and trailing \n inside <div> so this would be escaped.

Anyway, markdown seems to work very well.

ronisbr commented 10 months ago

Ok! Thanks!