houfu / redlines

Show the differences between two strings/text as a compact text, in markdown/HTML, in the terminal and more.
https://houfu.github.io/redlines/
MIT License
110 stars 6 forks source link

Styling doesn't work in Colab #20

Closed houfu closed 10 months ago

houfu commented 1 year ago

I've added notes on how to get your styling to show in environments such as Streamlit and Github. See #17

Now you can add Colab to this list. The main issue is some environments do not render HTML code found in markdown, and the markdown standard is not consistent in showing deletions and insertions.

Currently, the only way to make it work is to set the markdown_style argument in Redlines as "none".

TODO: Update the documentation to reflect what we can do for Colab.

bkowshik commented 1 year ago

output_rich

This looks as expected on Google Colab.

Redlines('This is an expariment.', 'This is an experiment', markdown_style=None).output_rich
Screenshot 2023-08-27 at 20 06 36

output_markdown

This does not render properly though.

Redlines('This is an expariment.', 'This is an experiment').output_markdown
This is an <span style='color:red;font-weight:700;text-decoration:line-through;'>expariment.</span><span style='color:green;font-weight:700;'>experiment</span>
Screenshot 2023-08-27 at 20 11 33
Markdown(Redlines('This is an expariment.', 'This is an experiment', markdown_style=None).output_markdown)

Adding the markdown_style=None did not help either. It looks exactly the same as before.

houfu commented 1 year ago

Woah I wasn't aware that output_rich works in Colab. We should put that down too.

I couldn't reproduce None not working though. Here's my test colab notebook: https://colab.research.google.com/drive/1RrpeKylF5UjB2X3g6qyXnZyp2to1cLQX?usp=sharing

I don't use Colab often enough, so maybe I am missing something. Maybe your environment is set up differently?

bkowshik commented 1 year ago

This is what I meant, the code snippet below gives me the following output:

test = Redlines('This is an expariment.', 'This is an experiment')
display(Markdown(test.output_markdown))
Screenshot 2023-08-29 at 23 38 53
houfu commented 1 year ago

OK that's expected because colab disregards any HTML code.

This one works though. Does it work for you @bkowshik ? image

bkowshik commented 1 year ago

Yes, this works for me on Google Colab. Why is markdown_style taking "none" (string) instead of None?

houfu commented 1 year ago

Interesting. My original thought was that "none" was a style, not that it was not a style. The default (iirc) is "red-green", so I don't expect someone to pass None

houfu commented 10 months ago

Docs now suggest what to do for colab: https://houfu.github.io/redlines/redlines/redlines.html#colab