print_math
Stable function · Other
Tier: stable · Kind: function · Topic: Other
| Julia | TypeScript | Python | Rust | Go |
|---|---|---|---|---|
print_math | printMath | print_math | print_math | PrintMath |
Julia
print_math(expr, names, format::Symbol)
print_math(expr, names, format::Symbol) -> String
Print one expression, or one equation, as math under a set of declared names:
LaTeX for :markdown (Lean Math.printLatex), Typst math for :typst
(Math.printTypst).
expr is a decoded ESM expression (a number, a name or an operator node) or an
equation, an object with lhs and rhs (other fields, such as _comment, are
not printed), which prints as its two sides around = as in a document
(Source.eqExpr). names (any collection of strings) plays the part of the
variables a component declares: a name in it prints in its declared shape, and
the printer avoids spellings that would collide with it. The result is what a
document display holds, without its delimiters; it is meant for showing one
expression outside a document, so no template is in scope.
julia> print_math(Dict("lhs" => "y", "rhs" => Dict("op" => "+", "args" => ["a", "T"])), ["a", "T", "y"], :typst)
"y = a + T"
TypeScript
function printMath(expr: unknown, names: readonly string[], format: DocumentFormat): string
Print one expression, or one equation, as math under a set of declared names:
LaTeX for 'markdown' (Math.printLatex), Typst math for 'typst'
(Math.printTypst).
expr is an ESM expression (a number, a name or an operator node) or an
equation, an object with lhs and rhs (other fields, such as _comment,
are not printed), which prints as its two sides around = as in a document.
names plays the part of the variables a component declares: a name in it
prints in its declared shape, and the printer avoids spellings that would
collide with it. The result is what a document display holds, without its
delimiters; no template is in scope.
Python
print_math(expr: Any, names: Iterable[str], format: DocumentFormat | str) -> str
Print one expression, or one equation, as math under a set of declared
names: LaTeX for "markdown" (Math.printLatex), Typst math for
"typst" (Math.printTypst).
expr is an ESM expression (a number, a name or an operator node) or an
equation, a dict with lhs and rhs (other fields, such as
_comment, are not printed), which prints as its two sides around =
as in a document (Source.eqExpr). names plays the part of the
variables a component declares: a name in it prints in its declared shape,
and the printer avoids spellings that would collide with it. The result is
what a document display holds, without its delimiters; it is meant for
showing one expression outside a document, so no template is in scope.
Rust
pub fn print_math(expr: &Value, names: &[String], format: DocumentFormat) -> String
Print one expression, or one equation, as math under a set of declared
names: LaTeX for DocumentFormat::Markdown (Math.printLatex), Typst
math for DocumentFormat::Typst (Math.printTypst).
expr is an ESM expression (a number, a name or an operator node) or an
equation, an object with lhs and rhs (other fields, such as
_comment, are not printed), which prints as its two sides around = as
in a document (Source.eqExpr). names plays the part of
the variables a component declares: a name in it prints in its declared
shape, and the printer avoids spellings that would collide with it. The
result is what a document display holds, without its delimiters; it is
meant for showing one expression outside a document, so no template is in
scope.
Go
func PrintMath(expr any, names []string, f DocumentFormat) string
PrintMath prints one expression, or one equation, as math under a set of declared names: LaTeX for DocumentMarkdown (Lean Math.printLatex), Typst math for DocumentTypst (Math.printTypst).
expr is a decoded ESM expression (a number, a name or an operator node) or an equation, an object with lhs and rhs (other fields, such as _comment, are not printed), which prints as its two sides around = as in a document (Source.eqExpr). names plays the part of the variables a component declares: a name in it prints in its declared shape, and the printer avoids spellings that would collide with it. The result is what a document display holds, without its delimiters; it is meant for showing one expression outside a document, so no template is in scope.