This commit is contained in:
Jake Poznanski 2025-03-17 08:47:57 -07:00
parent 1e42e5ea9a
commit f2951f3f78

View File

@ -16,7 +16,6 @@ import json
import os
import pathlib
import re
import shutil
import sqlite3
import threading
import unittest
@ -28,6 +27,7 @@ from playwright.sync_api import sync_playwright
# --- New SQLite Cache Implementation ---
class EquationCache:
def __init__(self, db_path: Optional[str] = None):
if db_path is None:
@ -44,14 +44,16 @@ class EquationCache:
conn = sqlite3.connect(self.db_path)
c = conn.cursor()
# Added an 'error' column to store rendering errors
c.execute('''
c.execute(
"""
CREATE TABLE IF NOT EXISTS equations (
eq_hash TEXT PRIMARY KEY,
mathml TEXT,
spans TEXT,
error TEXT
)
''')
"""
)
conn.commit()
conn.close()
@ -126,6 +128,7 @@ equation_cache = EquationCache()
# Thread-local storage for Playwright and browser instances
_thread_local = threading.local()
@dataclass
class BoundingBox:
x: float