-
Notifications
You must be signed in to change notification settings - Fork 849
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
render_math: Fix for new MARKDOWN dict in Pelican 3.7 #787
Conversation
Thanks for the fix, Stefan. I will most likely merge getpelican/pelican#1927 soon so it can be included in the upcoming Pelican 3.7 release, at which point you will probably be asked to update this pull request. Apologies for the moving target! (^_^) |
Thanks for the heads up! Should I understand that the two repos are considered to be tightly coupled and there is no need for backwards compatibility with pelican 3.6.3? |
Backwards compatibility is always preferred but not strictly necessary. Now that Pelican 3.7 has been released, would you be so kind as to update this pull request to use the new |
Will do in a bit. |
Hi Stefan. Any updates on this? |
@justinmayer I made the change. It might not work on 3.6.4, but it should work on the current version and on versions before 3.6.4. I made the change somewhat blindly (I do not have understanding of what those options do, I just followed the changes described in the pull request that removed MD_EXTENSIONS). I did test it and it seems to work for me. |
if isinstance(pelicanobj.settings.get('MD_EXTENSIONS'), list): # pelican 3.6.3 and earlier | ||
pelicanobj.settings['MD_EXTENSIONS'].append(PelicanMathJaxExtension(config)) | ||
else: | ||
pelicanobj.settings['MARKDOWN']['extension_configs'].update({PelicanMathJaxExtension(config):{}}) |
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.
Class instance extensions should be added to the extensions
list, extension_configs
is only used for extensions loaded by name. See http://pythonhosted.org/Markdown/reference.html#markdown
pelicanobj.settings['MARKDOWN'].setdefault('extensions', []).append(PelicanMathJaxExtension(config))
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.
Well, that was embarrassing. I will make that change.
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.
@Krastanov yes please 👍
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.
So I tried both versions of the patch above and it isn't working. I think I'm having some conflict with the pelican-ipynb.liquid
plugin (some mathjax conflict?) because if I comment out the line
pelicanobj.settings['MARKDOWN'].setdefault('extensions', []).append(PelicanMathJaxExtension(config))```
then the latex is rendered properly. I'm running pelican-3.7.0
While you're at it, please fix the process_summary function also. At the moment I'm getting this warning: WARNING: _get_summary() has been deprecated since 3.6.4. Use the summary decorator instead and Mathjax is not loaded even if a summary contains math in index pages. |
@jar1karp I will try to track this down. |
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.
I feel like we need that for more plugins actually. liquid_tags too for instance.
if isinstance(pelicanobj.settings.get('MD_EXTENSIONS'), list): # pelican 3.6.3 and earlier | ||
pelicanobj.settings['MD_EXTENSIONS'].append(PelicanMathJaxExtension(config)) | ||
else: | ||
pelicanobj.settings['MARKDOWN']['extension_configs'].update({PelicanMathJaxExtension(config):{}}) |
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.
@Krastanov yes please 👍
Maybe we should add a shared helper that plugins can use for that. |
Re: the problem with auto-generated summaries -- it seems that the render_math plugin can't update the summary anymore as the get_summary method is memoized (changed in this commit). The plugin gets a truncated summary (i.e. the Mathjax code also gets truncated), does the cleanup and reinserts the Mathjax, but it doesn't actually change the summary. The html will be rendered using the truncated Mathjax so math will not display correctly. The plugin seems to work correctly if the memoized decorator is commented out for get_summary in contents.py. But I suppose it needs a cleaner fix, maybe a proper mechanism for plugins to be allowed to update summaries? In addition, if using summary plugin with render_math they have to be loaded in that order to work correctly (render_math would otherwise strip away the special summary marker comments). |
I broke the summary issue out into a new issue since it seems to be orthogonal to the basic markdown fix - although in fact there already exists one. See #784. |
The alternative pull request referenced above is a minor change - it adds the required math markdown extension instnce directly to the |
In (hopefully) conclusion:
|
Thanks to Stefan for the fix and to others for reviewing and assisting. Much obliged! (^_^) |
Is this a separately maintained version of render_math in getpelican/pelican-plugins? I didn't realize there were several versions. Here's the same issue in the original repo: |
Regarding @szhorvat's comment, I do wonder, what is the recommended practice when finding/fixing bugs in various Pelican plugins? I submitted a patch to this bug at the author's repo. (I mean, I guess so, but I didn't want to step on any toes...) |
When executing
which, as far as I understand, relates to this thread. I fetched all changes to the plugins. The sources in my case can be found here. How can I avoid this warning? |
… instead. See getpelican/pelican-plugins#787 for related
This extensions does not work with the current git version of pelican. This fix hopefully addresses the issue (works for me).