widgetti / solara

A Pure Python, React-style Framework for Scaling Your Jupyter and Web Apps
https://solara.dev
MIT License
1.92k stars 144 forks source link

Feature request: optionally disable katex in markdown #698

Open ntjess opened 5 months ago

ntjess commented 5 months ago

Consider the following string:

We made $4500 and then $4600 the next month

Solara renders this as:

image

We can manually escape $ ahead of time, but it is a complex procedure. Only pairs of $ render as math, and double-$$ pairs on their own lines. Ideally, we can just disable math output if we know it doesn't apply.

Also, since VSCode doesn't render math text anyway, this escaping produces visible backslashes in that environment:

image

Edit: Escaped dollars show their backslashes in the browser too. So it seems there is no way to properly render the sentence above in markdown?

So it seems the only way to get a uniform behavior is to allow users to disable math mode in browser.

iisakkirotko commented 5 months ago

Hey @ntjess!

Seems that $\$$ can be used to escape this trap. Note that this renders $ in mathematics mode, which will differ from any $ outside.

Either way, I think it would be nice to have a better way to mitigate this issue. I think the most optimal way to implement this would be to allow the user to determine which delimiters they wish to use for math rendering. What do you think of this approach? Would you like to open a PR for this, or should I take a look?

ntjess commented 5 months ago

Great idea, it somehow hadn't crossed my mind 😅 It solves the issue in solara run and jupyter notebook, but still shows raw characters in the vscode notebook preview:

image

There is a somewhat complicated template loading procedure so I'm not sure how helpful I could be...