-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Latex support #2696
Latex support #2696
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to vendor in the css and fonts here, that will be difficult to maintain. We can load them directly from the node package via katex/path/to/assets
. Vite can handle css and fonts.
I've implemented support for rendering mathtext serverside, a subset of latex that ships with matplotlib. Screenshot from demo/latex/run.py corresponding code: gr.Markdown(
r"""
# Hello World! $\frac{\sqrt{x + y}}{4}$ is today's lesson
## the $\sqrt{x + y}$ is first
Start with $\frac{\frac{x+1}{x+2}}{x+3}$ then we get $x+2$
There are three formulas to know:
the first is $\gamma^2 + \theta^2 = \omega^2$
$\sqrt{x^2+1}$ is next
Integral $\int_{a}^{b} x^2 \,dx$ is last
Start typing below to see the output.
""") |
nice! |
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
Very nice. I added some LaTeX to Two nits:
You might have to set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM besides a couple of nits (see above)
@abidlabs and how does it look in "dark mode"? |
@kashif good question -- it looks good to me: |
also there is a hidden formula span, so if you try to copy text with latex, it will render the formula. |
Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
… latex-support
@abidlabs I am not able to reproduce your warning - can you check if your suggestion works? |
I upgraded to the latest version of matplotlib and it is indeed throwing an error! Sure I'll see if I can fix it on my end |
Ok so I just removed the |
Now the Latex is rendered server-side so this concern is no longer relevant
The demo notebooks don't match the run.py files. Please run this command from the root of the repo and then commit the changes: pip install nbformat && cd demo && python generate_notebooks.py |
awesome! thanks! |
Description
Started to add math support for markdown
Closes: #538
Checklist:
A note about the CHANGELOG
Hello 👋 and thank you for contributing to Gradio!
All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.
Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by
[@myusername](link-to-your-github-profile)
in[PR 11111](https://github.com/gradio-app/gradio/pull/11111)
".If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.