Convert a {…} value string to SVG bytes. Returns cached bytes if available, renders fresh otherwise. Returns None when LaTeX rendering is disabled, the value is not an expression, SLiCAP is unavailable, or any step in the pipeline fails.
(value_str: str)
| 183 | |
| 184 | |
| 185 | def render_expression(value_str: str) -> bytes | None: |
| 186 | """ |
| 187 | Convert a {…} value string to SVG bytes. |
| 188 | |
| 189 | Returns cached bytes if available, renders fresh otherwise. |
| 190 | Returns None when LaTeX rendering is disabled, the value is not an |
| 191 | expression, SLiCAP is unavailable, or any step in the pipeline fails. |
| 192 | """ |
| 193 | if not LATEX_AVAILABLE: |
| 194 | return None |
| 195 | if not is_expression(value_str): |
| 196 | return None |
| 197 | expr_str = value_str.strip()[1:-1].strip() |
| 198 | return _render_cached(expr_str) |
| 199 | |
| 200 | |
| 201 | def expression_to_latex(value_str: str) -> str: |
no test coverage detected