Closed MrCool1981 closed 1 month ago
A valid KaTeX expression:
a_w = \frac{\text{moles}_{\text{water}}}{\text{moles}_{\text{water}} + \text{moles}_{\text{solute}}}
is successfully rendered using KaTeX tool: https://katex.org/
However, it is not displayed properly in gr.chatbot and gr.ChatInterface when wrapped in double $$:
$$a_w = \frac{\text{moles}_{\text{water}}}{\text{moles}_{\text{water}} + \text{moles}{\text{solute}}}$$
Once, the underscores are removed from denominator, the formula is displayed correctly:
$$a_w = \frac{\text{moles}_{\text{water}}}{\text{moles}{\text{water}} + \text{moles}{\text{solute}}}$$
The subscript text in the denominator is displayed correctly when "\text" tag is removed:
$$aw = \frac{moles_{water}}{moles_{water} + moles_{solute}}$$
import random import gradio as gr def random_response(message, history): return random.choice(["Yes", "No"]) demo = gr.ChatInterface(random_response) if __name__ == "__main__": demo.launch()
No response
gradio==4.31.5 Python 3.12.3
I can work around it
Thanks for opening this issue @MrCool1981! Cc @dawoodkhan82
Must be an issue with how we are parsing markdown. Will take a look.
Describe the bug
A valid KaTeX expression:
a_w = \frac{\text{moles}_{\text{water}}}{\text{moles}_{\text{water}} + \text{moles}_{\text{solute}}}
is successfully rendered using KaTeX tool: https://katex.org/
However, it is not displayed properly in gr.chatbot and gr.ChatInterface when wrapped in double $$:
$$a_w = \frac{\text{moles}_{\text{water}}}{\text{moles}_{\text{water}} + \text{moles}{\text{solute}}}$$
Once, the underscores are removed from denominator, the formula is displayed correctly:
$$a_w = \frac{\text{moles}_{\text{water}}}{\text{moles}{\text{water}} + \text{moles}{\text{solute}}}$$
The subscript text in the denominator is displayed correctly when "\text" tag is removed:
$$aw = \frac{moles_{water}}{moles_{water} + moles_{solute}}$$
Have you searched existing issues? 🔎
Reproduction
Screenshot
Logs
No response
System Info
Severity
I can work around it