-
Notifications
You must be signed in to change notification settings - Fork 197
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
Scrapper for Sympy output #1276
Comments
What is the output for Sympy? Does it output html? If so https://sphinx-gallery.github.io/stable/configuration.html#capture-repr may be useful? |
Thanks for the answer and sorry for my delayed response. |
Can you write a scraper for Sympy and just add the https://sphinx-gallery.github.io/stable/advanced.html#write-a-custom-image-scraper |
I am not sure how to do this. Mainly because the doc in scrapper is for images. How to go about capturing some mathML or latex output? I thought of using something like the |
Ok, I found a way to make mathjax render latex code. """
Testing sympy mathml
====================
"""
# %%
# Should show this
#
# .. math::
# \dot{x} = x y^2 - \frac{\sqrt{x}}{y}
#
from sympy import latex
from sympy.core.evalf import EvalfMixin
def print_html(expr):
return f'{latex(expr, mode="equation*", itex=True)}'
EvalfMixin._repr_html_ = print_html
from sympy import symbols, Symbol, Eq, sqrt
x, y = symbols("x y")
expr = Eq(Symbol(r"\dot{x}"), x * y ** 2 - sqrt(x) / y)
expr However, this however will not work with , e.g. mathimg extension (svg math). Could any give me a head start on how to produce a more robust solution (e.g. instead of monkey patching)? UPDATE: for gettgin matrices also rendered another class must be monkey patched
|
An image scraper is originally intended for images but essentially its a function that is run at the end of each code block and should return ReST that gets added to the example, after the code block. It could be made to work for Sympy. If you look at the matplotlib scrapper: sphinx-gallery/sphinx_gallery/scrapers.py Lines 149 to 154 in b091350
it iterates through all the figures via Alternatively I have found this comment: #1138 (comment), maybe Sympy uses mimebundle? |
Is there an scrapper for Sympy output?
Any hints?
Thanks!
The text was updated successfully, but these errors were encountered: