Просмотр исходного кода

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

Render Math: Workaround for processing summaries
Justin Mayer лет назад: 8
Родитель
Сommit
a6c61ab61e
1 измененных файлов с 7 добавлено и 1 удалено
  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
     """Ensures summaries are not cut off. Also inserts
     mathjax script so that math will be rendered"""
     mathjax script so that math will be rendered"""
 
 
-    summary = article._get_summary()
+    summary = article.summary
     summary_parsed = BeautifulSoup(summary, 'html.parser')
     summary_parsed = BeautifulSoup(summary, 'html.parser')
     math = summary_parsed.find_all(class_='math')
     math = summary_parsed.find_all(class_='math')
 
 
@@ -199,6 +199,12 @@ def process_summary(article):
             math[-1].string = "%s ..." % full_text
             math[-1].string = "%s ..." % full_text
             summary = summary_parsed.decode()
             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)
         article._summary = "%s<script type='text/javascript'>%s</script>" % (summary, process_summary.mathjax_script)
 
 
 def configure_typogrify(pelicanobj, mathjax_settings):
 def configure_typogrify(pelicanobj, mathjax_settings):