chiark / gitweb /
Make the latex2svg caching fully optional.
authorVladimír Vondruš <mosra@centrum.cz>
Wed, 13 Jun 2018 10:20:07 +0000 (12:20 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sun, 17 Jun 2018 11:06:50 +0000 (13:06 +0200)
pelican-plugins/latex2svgextra.py

index 7187e83c1870c07135e418d91b70e5c6cb66f997..2ffc33c69de42eea3618d1b507ad3e3f4d49a68a 100644 (file)
@@ -76,11 +76,13 @@ _cache = None
 def fetch_cached_or_render(formula):
     global _cache
 
-    # unpickle_cache() should be called first
-    assert _cache
+    # Cache not used, pass through
+    if not _cache:
+        out = latex2svg.latex2svg(formula, params=params)
+        return out['depth'], out['svg']
 
     hash = sha1(formula.encode('utf-8')).digest()
-    if not _cache or not hash in _cache[2]:
+    if not hash in _cache[2]:
         out = latex2svg.latex2svg(formula, params=params)
         _cache[2][hash] = (_cache[1], out['depth'], out['svg'])
     else: