sphinx-extensions2 / sphinx-tippy

Get rich tool tips in your sphinx documentation!
https://sphinx-tippy.readthedocs.io
MIT License
33 stars 5 forks source link

Math references not working in different themes #6

Closed IngoSteldermann closed 1 year ago

IngoSteldermann commented 1 year ago

Thanks for this amazing project! Having nice references was one major factor for us to start converting classical pdf-lecture content as sphinx/jupyterbook hmtl content for our students.

Problem: Math references do not show any tooltip while hovering, if I use the "pydata-sphinx-theme" or "sphinx-book-theme". For the "furo" theme, everything works as expected.

Reproducibility/Minimal example: Building the sphinx-tippy documentation as it is (with theme: "furo"), everything works as expected. Changing the conf.py (using the changes needed for the "pydata-sphinx-theme" according to the sphinx-tippy docs):

html_theme = "pydata_sphinx_theme"
html_static_path = ['_static']
html_css_files = ["tippy.css"]
tippy_anchor_parent_selector = "article.bd-article" #not necessary

and setting up the file _static/tippy.css:

.tippy-box {
    background-color:var(--pst-color-surface);
    color:var(--pst-color-text-base);
    border: 1px solid var(--pst-color-border);
}

Building the project shows the expected documentation in the new theme. All references, except the math reference, are working.

Causes/Possible Solutions: I am not quite sure if this is just a matter of configuration or not. Since hovering over the math reference causes no response from tippy, I would assume that the equation is not detected by tippy? However, this would mean that different themes treat mathjax equations differently (at least for their default settings). I am not sure if this is true. Do you have any ideas?

Best, Ingo

Breakidawn commented 1 year ago

Thanks for this amazing project! Having nice references was one major factor for us to start converting classical pdf-lecture content as sphinx/jupyterbook hmtl content for our students.

Problem: Math references do not show any tooltip while hovering, if I use the "pydata-sphinx-theme" or "sphinx-book-theme". For the "furo" theme, everything works as expected.

Reproducibility/Minimal example: Building the sphinx-tippy documentation as it is (with theme: "furo"), everything works as expected. Changing the conf.py (using the changes needed for the "pydata-sphinx-theme" according to the sphinx-tippy docs):

html_theme = "pydata_sphinx_theme"
html_static_path = ['_static']
html_css_files = ["tippy.css"]
tippy_anchor_parent_selector = "article.bd-article" #not necessary

and setting up the file _static/tippy.css:

.tippy-box {
    background-color:var(--pst-color-surface);
    color:var(--pst-color-text-base);
    border: 1px solid var(--pst-color-border);
}

Building the project shows the expected documentation in the new theme. All references, except the math reference, are working.

Causes/Possible Solutions: I am not quite sure if this is just a matter of configuration or not. Since hovering over the math reference causes no response from tippy, I would assume that the equation is not detected by tippy? However, this would mean that different themes treat mathjax equations differently (at least for their default settings). I am not sure if this is true. Do you have any ideas?

Best, Ingo

It may be caused by putting "math notranslate nohighlight" under "math-wrapper docutils container" in the "furo" theme.

You can add tippy_tip_selector = "figure, table, img, p, aside, div.admonition, div.literal-block-wrapper, div.math" in your conf.py.

https://github.com/sphinx-extensions2/sphinx-tippy/blob/cca8ea804fba5a7dde52a6d2d4d00eb191acd825/src/sphinx_tippy.py#L402

Or,I think you can irresponsibly change "math-wrapper" to "math".

IngoSteldermann commented 1 year ago

Thanks a lot. The tippy_tip_selector="div.math" was missing in my config and it does the trick. Thanks a lot!