Rule: {
    condition?: LatexString | PatternConditionFunction;
    id?: string;
    match: LatexString | SemiBoxedExpression | Pattern;
    priority?: number;
    replace: LatexString | SemiBoxedExpression | PatternReplaceFunction;
}

A rule describes how to modify an expressions that matches a pattern match into a new expression replace.

x-1 ( \to ) 1-x (x+1)(x-1) ( \to ) `x^2-1

The match pattern can be expressed as a LaTeX string or a MathJSON expression.

Anonymous wildcards (_) will match any expression. Named wildcards (_x, _a, etc...) will match any expression and bind the expression to the wildcard name.

In addition the sequence wildcard (__1, __a, etc...) will match a sequence of one or more expressions, and bind the sequence to the wildcard name.