Idenso · latest
On this page

to_html

symbolica.community.tensor Function

to_html(expression: Expression, show_dimensions: Optional[bool] = None, *, settings: Optional[DisplaySettings] = None, notation_source: Optional[str] = None) -> str

Render the tensor as an HTML fragment.

Parameters

expression Expression

Symbolica tensor syntax or scalar algebra to display. For a TensorExpression or component Tensor, prefer its formatting methods.

show_dimensions bool, optional

Override settings.show_dimensions for this call. None retains the selected settings, whose default omits dimensions.

settings DisplaySettings, optional

Tensor notation and display choices. Defaults to DisplaySettings().

notation_source str, optional

Unsupported for HTML and notebook output; raises ValueError. Use to_typst_project() or to_svg() for custom Typst notation.

Returns

str

Self-contained output fragment for an HTML-capable notebook or page.

Notes

Mathematical rendering uses direct MathML and requires no Typst compiler. The complete expression is exported; oversized output raises an error. Pass the returned string to the notebook's HTML display facility.

# Errors

Returns ValueError for Typst notation or incomplete MathML. Registered Python printer exceptions are logged and decline the override, allowing native fallback.

Examples

from symbolica import S
expression = S("x") + 1
from symbolica.community.tensor import to_html
output = to_html(expression)