interface Serializer {
    applyFunctionStyle: ((expr: Expression, level: number) =>
        | "big"
        | "none"
        | "paren"
        | "leftright");
    canonical?: boolean;
    fractionStyle: ((expr: Expression, level: number) =>
        | "quotient"
        | "block-quotient"
        | "inline-quotient"
        | "inline-solidus"
        | "nice-solidus"
        | "reciprocal"
        | "factor");
    groupStyle: ((expr: Expression, level: number) =>
        | "big"
        | "none"
        | "paren"
        | "leftright");
    level: number;
    logicStyle: ((expr: Expression, level: number) =>
        | "boolean"
        | "word"
        | "uppercase-word"
        | "punctuation");
    numericSetStyle: ((expr: Expression, level: number) =>
        | "compact"
        | "regular"
        | "interval"
        | "set-builder");
    onError: WarningSignalHandler;
    options: Required<SerializeLatexOptions>;
    powerStyle: ((expr: Expression, level: number) => "root" | "quotient" | "solidus");
    rootStyle: ((expr: Expression, level: number) => "quotient" | "radical" | "solidus");
    serialize: ((expr: null | Expression) => string);
    wrap: ((expr: null | Expression, prec?: number) => string);
    serializeFunction(expr: Expression): string;
    serializeSymbol(expr: Expression): string;
    wrapArguments(expr: Expression): string;
    wrapShort(expr: null | Expression): string;
    wrapString(s: string, style:
        | "big"
        | "none"
        | "paren"
        | "leftright", fence?: string): string;
}

Properties

applyFunctionStyle: ((expr: Expression, level: number) =>
    | "big"
    | "none"
    | "paren"
    | "leftright")

Styles

canonical?: boolean

If true, apply transformations to the expression so the output doesn't necesarily match the raw MathJSON, but is more visually pleasing and easier to read. If false, output the raw MathJSON.

fractionStyle: ((expr: Expression, level: number) =>
    | "quotient"
    | "block-quotient"
    | "inline-quotient"
    | "inline-solidus"
    | "nice-solidus"
    | "reciprocal"
    | "factor")
groupStyle: ((expr: Expression, level: number) =>
    | "big"
    | "none"
    | "paren"
    | "leftright")
level: number

"depth" of the expression:

  • 0 for the root
  • 1 for the arguments of the root
  • 2 for the arguments of the arguments of the root
  • etc...

This allows for variation of the LaTeX serialized based on the depth of the expression, for example using \Bigl( for the top level, and \bigl( or ( for others.

logicStyle: ((expr: Expression, level: number) =>
    | "boolean"
    | "word"
    | "uppercase-word"
    | "punctuation")
numericSetStyle: ((expr: Expression, level: number) =>
    | "compact"
    | "regular"
    | "interval"
    | "set-builder")
powerStyle: ((expr: Expression, level: number) => "root" | "quotient" | "solidus")
rootStyle: ((expr: Expression, level: number) => "quotient" | "radical" | "solidus")
serialize: ((expr: null | Expression) => string)

Output a LaTeX string representing the expression

wrap: ((expr: null | Expression, prec?: number) => string)

Add a group fence around the expression if it is an operator of precedence less than or equal to prec.

Methods

  • Parameters

    Returns string

  • Parameters

    Returns string

  • A string with the arguments of expr fenced appropriately and separated by commas.

    Parameters

    Returns string

  • Add a group fence around the expression if it is short (not a function)

    Parameters

    Returns string

  • Parameters

    • s: string
    • style:
          | "big"
          | "none"
          | "paren"
          | "leftright"
    • Optionalfence: string

    Returns string