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

Function render_name_eq_value

SLiCAP/schematic/latex_label.py:166–182  ·  view source on GitHub ↗

Render '\text{name} = value' as SVG for component labels (show_name=True). Uses _latex_to_svg directly (not _render_cached) so the combined LaTeX string is never passed through the SymPy parser.

(name: str, value_str: str)

Source from the content-addressed store, hash-verified

164
165
166def render_name_eq_value(name: str, value_str: str) -> bytes | None:
167 """
168 Render '\text{name} = value' as SVG for component labels (show_name=True).
169
170 Uses _latex_to_svg directly (not _render_cached) so the combined LaTeX
171 string is never passed through the SymPy parser.
172 """
173 if not LATEX_AVAILABLE:
174 return None
175 safe = name.replace('_', r'\_').replace('^', r'\^{}')
176 val = value_str.strip()
177 if not (val.startswith("{") and val.endswith("}")):
178 val = "{" + val + "}"
179 val_tex = expression_to_latex(val)
180 if not val_tex:
181 val_tex = val[1:-1]
182 return _render_latex_str(rf"{{\footnotesize \textsf{{{safe}}}}} = {val_tex}")
183
184
185def render_expression(value_str: str) -> bytes | None:

Callers 1

update_labelsMethod · 0.85

Calls 2

expression_to_latexFunction · 0.85
_render_latex_strFunction · 0.85

Tested by

no test coverage detected