pelican-plugins / render-math

Pelican plugin that renders mathematics via the MathJax JavaScript engine
Other
29 stars 7 forks source link

Cannot render math in summaries #18

Open beetleb opened 2 years ago

beetleb commented 2 years ago

Math renders fine in articles, but not in summaries.

I do not manually specify summaries - Pelican autogenerates them.

process_summary in MATH_JAX is set to True.

I've manually confirmed that the process_summary function is called, and it indeed is adding the "summary" key to the article metadata, with appropriate MathJax content, but it doesn't show up in the final HTML.

I've disabled all other plugins - that didn't change anything.

I've spent the last few hours debugging - I have no idea what to do.

Pelican Version is 4.5.3

render-math version is the latest commit.

Ideas?

Thanks.

ghost commented 1 year ago

I just want to add my experience to this. Installing this plugin and using the default settings also did not allow me to render math in summaries, even with beautifulsoup4 installed as the documentation instructs. A large blob of javascript was inserted as text in the rendered summary.

I did find a workaround that appears to work. I have disabled both summary processing and auto inserting mathjax and instead load mathjax from the template instead:

# in pelicanconf.py
MATH_JAX = {
    "auto_insert": False,
    "process_summary": False,
}
<!-- templates/base.html in the template you use-->
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

There is probably a downside to not having process_summary enabled and working as intended, the documentation mentions that it will deal with math that got cut off during the generating of the summary. I have not done thorough testing of this workaround.