Browse Source

Merge pull request #973 from lhofmann/render_math-summary-workaround

Render Math: Workaround for processing summaries
Justin Mayer 6 years ago
parent
commit
a6c61ab61e
1 changed files with 7 additions and 1 deletions
  1. 7 1
      render_math/math.py

+ 7 - 1
render_math/math.py

@@ -187,7 +187,7 @@ def process_summary(article):
     """Ensures summaries are not cut off. Also inserts
     mathjax script so that math will be rendered"""
 
-    summary = article._get_summary()
+    summary = article.summary
     summary_parsed = BeautifulSoup(summary, 'html.parser')
     math = summary_parsed.find_all(class_='math')
 
@@ -199,6 +199,12 @@ def process_summary(article):
             math[-1].string = "%s ..." % full_text
             summary = summary_parsed.decode()
 
+        # clear memoization cache
+        import functools
+        if isinstance(article.get_summary, functools.partial):
+            memoize_instance = article.get_summary.func.__self__
+            memoize_instance.cache.clear()
+
         article._summary = "%s<script type='text/javascript'>%s</script>" % (summary, process_summary.mathjax_script)
 
 def configure_typogrify(pelicanobj, mathjax_settings):