MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / _render_latex_str

Function _render_latex_str

SLiCAP/schematic/latex_label.py:271–282  ·  view source on GitHub ↗

Cache and render a pre-built LaTeX math string, bypassing SymPy parsing.

(latex_str: str)

Source from the content-addressed store, hash-verified

269
270
271def _render_latex_str(latex_str: str) -> bytes | None:
272 """Cache and render a pre-built LaTeX math string, bypassing SymPy parsing."""
273 if not LATEX_AVAILABLE:
274 return None
275 h = hashlib.sha256(("raw:" + latex_str).encode()).hexdigest()[:24]
276 path = get_cache_dir() / f"{h}.svg"
277 if path.exists():
278 return path.read_bytes()
279 svg = _latex_to_svg(latex_str)
280 if svg is not None:
281 path.write_bytes(svg)
282 return svg
283
284
285def _latex_to_svg(latex_str: str) -> bytes | None:

Callers 1

render_name_eq_valueFunction · 0.85

Calls 2

get_cache_dirFunction · 0.85
_latex_to_svgFunction · 0.85

Tested by

no test coverage detected