fmt.spad line 416 [edit on github]
undocumented
altsupersub(p)
returns a handler such that altsupersub(p)(prec, args)
formats the first argument with respect to the precedence p
. The remaining arguments are formatted without parentheses and interpreted as subscript, superscript, subscript, superscript, etc. where the subscripts and superscripts are pairwise aligned. Outer parentheses are added if p < prec
.
binary(h1, h2)
returns a handler h
such that h(prec, args)
formats the first argument according to h1
and the second argument by h2
. Both boxes will be horizontally concatenated. binary(h1
, h2
) is equal to infix(""
, maxPrecedence(), h1
, h2
)
binomial
is a handler such that binomial(prec,args)
formats a binomial expression of the first two arguments.
box(hh)
returns a handler h
such that h(prec, args)
formats the arguments via hh(prec, args)
and then draws a box frame around the resulting box.
bracket(lb, rb, hh)
returns a handler h
such that h(prec, args)
formats its first argument according to hh
and then put left and right brackets given by lb
and rb
around the resulting box.
defaultEpilogue(label)
returns a box that is used at the end of every format.
defaultPrologue(label)
returns a box that is used at the beginning of every format.
formatConstant(op)
is a handler to format constant operators.
formatExpression(p)
returns a handler h
that h(prec, args)
returns formatExpression(first args, p)
. This handler is used to change the precedence context in which the argument is formatted.
formatExpression(o)
returns formatExpression(o, minPrecedence())
.
formatExpression(o, p)
returns an OutputBox that represent the expression o
in the respective format when considered in a context with outer precedence p
. This function is the main dispatcher function. It first checks whether o
is an integer or a string and treats these cases. Then, if the number n
of arguments is less than 3, it tries to find a handler for the top-level operator of o
. If none is found, it checks for a handler of an n
-ary operator. If no handler is found, the operator is treated as a function symbol and formatted as such.
formatFloat(s)
formats a floating point number from it string representation in OutputForm.
formatFunction(b, args)
is supposed to create a box for "b
(args)", i.e. format the list of arguments given by args an put it into a format that represents a function application.
formatFunctionSymbol(s)
formats an otherwise unknown function symbol.
formatInteger(n)
formats an integer.
formatString(s)
formats a string.
formatSymbol(s)
formats a symbol.
Format a fraction. fraction(p, h1, h2)
returns a handler h
such that h(prec, args)
formats the first argument by h1
and the second argument by h2
. Outer parentheses are added if p < prec
.
function(s, p, hh)
is meant to typeset function applications. It defaults to prefix(s
,p
,bracket("(",")",hh
)).
infix(op, p, h1, h2)
returns a handler h
such that h(prec, args)
formats the first argument by h1
and the second argument by h2
. Both boxes will be horizontally concatenated with box op
in the middle. Outer parentheses are added if p < prec
.
integral(p)
returns a handler h
such that h(prec, args)
formats the expression as an integral with integral sign and respective limits. Outer parentheses are added if p < prec
.
matrix(left, right)
returns a handler that typesets a matrix with parentheses given by left
and right where rows are formatted using h
.
maxPrecedence()
returns the maximal precedence value,
minPrecedence()
returns the minimal precedence value.
nary(s, p, hh)
returns a handler h
such that h(prec, args)
formats each argument according to hh
. All resulting boxes will be horizontally concatenated with box s
inbetween. Outer parentheses are added if p < prec
.
nary(plus, minus, p, hh)
returns a handler h
such that h(prec, args)
formats each argument according to hh
. All resulting boxes will be horizontally concatenated with box minus
or box plus
inbetween depending on whether the respective argument starts with a unary minus
or not. Outer parentheses are added if p < prec
. This is a special handler that treats the case that a sum is represented as a nary expression that contains unary subexpressions that are unary minus
expressions. This handler transforms something like (+ a (- b
)) into a - b
.
nothing()
returns a handler h
such that h(prec, args)
returns an empty box. This corresponds to NOTHING in OutputForm
.
Format square roots and n
th roots. nthRoot(p, h1, h2)
returns a handler h
such that h(prec, args)
formats the first argument according to h1
. If there is no second argument, then the n
th root is a square root and formatted accordingly. Otherwise the second argument is formatted by h2
. Outer parentheses are added if p < prec
.
numberOfPrimes(e)
counts the number of commas in e
and returns it. If s
does not only contain commas, but has a parenthesis at the beginning and the end of the string, then the part between the parentheses is interpreted as a roman numeral and translated into an integer. For any other format the function returns -1
.
operatorHandlers()
returns an internal data structure that is used for the selection of respective handlers.
overbar(p, hh)
returns a handler h
such that h(prec, args)
formats arguments via hh(p, args)
and then draws a bar over the resulting box. Outer parentheses are added if p < prec
.
parenthesize(lb, rb, bx)
returns the box bx
with left and right brackets (lb
and rb
) around it.
parenthesizeIf(paren?, bx)
returns parentheses (of appropriate size if paren?
is true
. Otherwise, bx
is returned.
pile()
returns a handler h
such that h(prec, args)
formats args according to hh
and then puts them on top of each other left adjusted. The baseline corresponds to the baseline of the first argument.
power(op, p, h1, h2)
returns a handler h
such that h(prec, args)
formats args.1
and args.2
according to h1
and h2
, respectively. Outer parentheses are added if p < prec
.
precedence(p, hh)
returns a handler h
such that h(prec, args)
returns hh(p, args)
. This handler can be used to change the context in which an expression is formatted.
prefix(s, p, hh)
returns a handler h
such that h(prec, args)
formats args according to hh
and then prefixes this box by box s
. Outer parentheses are added if p < prec
.
prime(p)
returns a handler that treats the typesetting of primes. Note that differentiate(a, 3) gives the following s
-expression in OutputForm: (PRIME a ",,,") whereas differentiate(a+b, 4) gives: (PRIME (+ a b
) (PAREN "iv")). the precedence p1
. Outer parentheses are added if p < prec
. See also the auxiliary function numberOfPrimes
.
product(p)
returns a handler h
such that h(prec, args)
formats a product with product sign and respective limits. Outer parentheses are added if p < prec
.
Formats super- and subscripts also presuper and presub. scripts(p)
returns a handler h
such that h(prec, args)
formats the first argument with respect to the precedence p
. The other arguments are interpreted as subscript, superscript, presuperscript, and presubscript (in this order). Outer parentheses are added if p < prec
.
Format a fraction linearly. slash(p, h1, h2)
returns a handler h
such that h(prec, args)
formats the first argument according to h1
and the second argument by h2
. Outer parentheses are added if p < prec
.
subscript(p)
returns a handler such that subscript(p)(prec, args)
formats the first argument with respect to the precedence p
. The other arguments are formatted without parentheses and interpreted as subscripts separated by commas. Outer parentheses are added if p < prec
.
sum(p)
returns a handler h
such that h(prec, args)
formats a sum expression with summation sign and respective limits. Outer parentheses are added if p < prec
.
theMap
is a special handler to format a function.
vconcat(hh)
returns a handler h
such that h(prec, args)
formats args according to hh
and then puts them on top of each other where the lines are centered. The baseline corresponds to the baseline of the first argument.
zag
is a handler such that zag(prec, args)
formats one part of a continued fraction.