Skip to content
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

Does not render math in autosummary table #18

Open
goerz opened this issue Mar 14, 2020 · 6 comments
Open

Does not render math in autosummary table #18

goerz opened this issue Mar 14, 2020 · 6 comments

Comments

@goerz
Copy link

goerz commented Mar 14, 2020

It seems that math is not rendered inside an autosummary table. That is, if the first line of a function docstring contains dollar-enclosed math, then having that function in an autosummary directive will result in table where the math is not rendered.

The math rendering works fine when displaying the entire function docstring via an automodule directive.

@goerz
Copy link
Author

goerz commented Mar 14, 2020

Blocks goerz/cookiecutter-pypackage#14 (this is just so that I have this issue status shown there)

@asmeurer
Copy link
Member

Sorry I didn't notice this earlier. This is probably just a question of modifying the node blacklist, which you can also do manually (see https://github.com/sympy/sphinx-math-dollar#configuration).

@APN-Pucky
Copy link

Thanks, excluding comment and paragraph from the blacklist worked for me.

from docutils.nodes import FixedTextElement, literal,math
from docutils.nodes import  comment, doctest_block, image, literal_block, math_block, paragraph, pending, raw, rubric, substitution_definition, target
math_dollar_node_blacklist = (literal,math,doctest_block, image, literal_block,  math_block,  pending,  raw,rubric, substitution_definition,target)

@asmeurer
Copy link
Member

Is the problem that the node that you want to include math is a FixedTextElement?

Feel free to make a PR fixing the default blacklist in the code.

@APN-Pucky
Copy link

APN-Pucky commented Dec 15, 2020

I think so. I just went through it by trial and error and apparently, in my case, comment and paragraph (which are FixedTextElements) caused autosummary to not display the math. I won't PR since I have no clue about side effects of this.

@asmeurer
Copy link
Member

I picked FixedTextElement because it seemed like it was the superclass of the nodes that I wanted to avoid (like the doctest node). You can see all the nodes here https://github.com/docutils-mirror/docutils/blob/e88c5fb08d5cdfa8b4ac1020dd6f7177778d5990/docutils/nodes.py. One thing confuses me, which is that paragraph does not appear to be a FixedTextElement https://github.com/docutils-mirror/docutils/blob/e88c5fb08d5cdfa8b4ac1020dd6f7177778d5990/docutils/nodes.py#L1577. Perhaps this isn't actually related. Furthermore, Sphinx itself adds several nodes that are FixedTextElement, which appear to be the sort of thing that should be blacklisted https://github.com/sphinx-doc/sphinx/blob/cc7396501603fec57222084b2487768c54cbd93c/sphinx/addnodes.py.

If you build the docs with the default configuration and MATH_DOLLAR_DEBUG=1, it should output which nodes are skipped. Which nodes does it say are not being included? It only prints it for nodes that appear to have dollar math, so be sure to add some LaTeX somewhere where it isn't working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants