FormatterCategory¶
fmt.spad line 416 [edit on github]
undocumented
- altsupersub: Integer -> (Integer, List OutputForm) -> OutputBox
altsupersub(p)
returns a handler such thataltsupersub(p)(prec, args)
formats the first argument with respect to the precedencep
. 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 ifp < prec
.
- binary: ((Integer, List OutputForm) -> OutputBox, (Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
binary(h1, h2)
returns a handlerh
such thath(prec, args)
formats the first argument according toh1
and the second argument byh2
. Both boxes will be horizontally concatenated. binary(h1
,h2
) is equal to infix(""
, maxPrecedence(),h1
,h2
)
- binomial: (Integer, List OutputForm) -> OutputBox
binomial
is a handler such thatbinomial(prec,args)
formats a binomial expression of the first two arguments.
- box: ((Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
box(hh)
returns a handlerh
such thath(prec, args)
formats the arguments viahh(prec, args)
and then draws a box frame around the resulting box.
- bracket: (String, String, (Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
bracket(lb, rb, hh)
returns a handlerh
such thath(prec, args)
formats its first argument according tohh
and then put left and right brackets given bylb
andrb
around the resulting box.
- coerce: % -> OutputForm
from CoercibleTo OutputForm
- defaultEpilogue: String -> OutputBox
defaultEpilogue(label)
returns a box that is used at the end of every format.
- defaultPrologue: String -> OutputBox
defaultPrologue(label)
returns a box that is used at the beginning of every format.
- formatConstant: String -> (Integer, List OutputForm) -> OutputBox
formatConstant(op)
is a handler to format constant operators.
- formatExpression: (OutputForm, Integer) -> OutputBox
formatExpression(o, p)
returns an OutputBox that represent the expressiono
in the respective format when considered in a context with outer precedencep
. This function is the main dispatcher function. It first checks whethero
is an integer or a string and treats these cases. Then, if the numbern
of arguments is less than 3, it tries to find a handler for the top-level operator ofo
. If none is found, it checks for a handler of ann
-ary operator. If no handler is found, the operator is treated as a function symbol and formatted as such.
- formatExpression: Integer -> (Integer, List OutputForm) -> OutputBox
formatExpression(p)
returns a handlerh
thath(prec, args)
returnsformatExpression(first args, p)
. This handler is used to change the precedence context in which the argument is formatted.
- formatExpression: OutputForm -> OutputBox
formatExpression(o)
returnsformatExpression(o, minPrecedence())
.
- formatFloat: String -> OutputBox
formatFloat(s)
formats a floating point number from it string representation in OutputForm.
- formatFunction: (OutputBox, List OutputBox) -> OutputBox
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: String -> OutputBox
formatFunctionSymbol(s)
formats an otherwise unknown function symbol.
- fraction: (Integer, (Integer, List OutputForm) -> OutputBox, (Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
Format a fraction.
fraction(p, h1, h2)
returns a handlerh
such thath(prec, args)
formats the first argument byh1
and the second argument byh2
. Outer parentheses are added ifp < prec
.
- function: (String, Integer, (Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
function(s, p, hh)
is meant to typeset function applications. It defaults to prefix(s
,p
,bracket(“(“,”)”,hh
)).
- infix: (String, Integer, (Integer, List OutputForm) -> OutputBox, (Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
infix(op, p, h1, h2)
returns a handlerh
such thath(prec, args)
formats the first argument byh1
and the second argument byh2
. Both boxes will be horizontally concatenated withbox op
in the middle. Outer parentheses are added ifp < prec
.
- integral: Integer -> (Integer, List OutputForm) -> OutputBox
integral(p)
returns a handlerh
such thath(prec, args)
formats the expression as an integral with integral sign and respective limits. Outer parentheses are added ifp < prec
.
- matrix: (String, String) -> (Integer, List OutputForm) -> OutputBox
matrix(left, right)
returns a handler that typesets a matrix with parentheses given byleft
and right where rows are formatted usingh
.
- maxPrecedence: () -> Integer
maxPrecedence()
returns the maximal precedence value,
- minPrecedence: () -> Integer
minPrecedence()
returns the minimal precedence value.
- nary: (String, Integer, (Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
nary(s, p, hh)
returns a handlerh
such thath(prec, args)
formats each argument according tohh
. All resulting boxes will be horizontally concatenated withbox s
inbetween. Outer parentheses are added ifp < prec
.
- naryPlus: (String, String, Integer, (Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
nary(plus, minus, p, hh)
returns a handlerh
such thath(prec, args)
formats each argument according tohh
. All resulting boxes will be horizontally concatenated withbox minus
orbox plus
inbetween depending on whether the respective argument starts with a unaryminus
or not. Outer parentheses are added ifp < 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 unaryminus
expressions. This handler transforms something like (+ a (-b
)) into a -b
.
- nothing: () -> (Integer, List OutputForm) -> OutputBox
nothing()
returns a handlerh
such thath(prec, args)
returns an empty box. This corresponds to NOTHING inOutputForm
.
- nthRoot: (Integer, (Integer, List OutputForm) -> OutputBox, (Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
Format square roots and
n
th roots.nthRoot(p, h1, h2)
returns a handlerh
such thath(prec, args)
formats the first argument according toh1
. If there is no second argument, then then
th root is a square root and formatted accordingly. Otherwise the second argument is formatted byh2
. Outer parentheses are added ifp < prec
.
- numberOfPrimes: OutputForm -> Integer
numberOfPrimes(e)
counts the number of commas ine
and returns it. Ifs
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: () -> OperatorHandlers((Integer, List OutputForm) -> OutputBox)
operatorHandlers()
returns an internal data structure that is used for the selection of respective handlers.
- overbar: (Integer, (Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
overbar(p, hh)
returns a handlerh
such thath(prec, args)
formats arguments viahh(p, args)
and then draws a bar over the resulting box. Outer parentheses are added ifp < prec
.
- parenthesize: (String, String, OutputBox) -> OutputBox
parenthesize(lb, rb, bx)
returns the boxbx
with left and right brackets (lb
andrb
) around it.
- parenthesizeIf: (Boolean, OutputBox) -> OutputBox
parenthesizeIf(paren?, bx)
returns parentheses (of appropriate size ifparen?
istrue
. Otherwise,bx
is returned.
- pile: ((Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
pile()
returns a handlerh
such thath(prec, args)
formats args according tohh
and then puts them on top of each other left adjusted. The baseline corresponds to the baseline of the first argument.
- power: (Integer, (Integer, List OutputForm) -> OutputBox, (Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
power(op, p, h1, h2)
returns a handlerh
such thath(prec, args)
formatsargs.1
andargs.2
according toh1
andh2
, respectively. Outer parentheses are added ifp < prec
.
- precedence: (Integer, (Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
precedence(p, hh)
returns a handlerh
such thath(prec, args)
returnshh(p, args)
. This handler can be used to change the context in which an expression is formatted.
- prefix: (String, Integer, (Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
prefix(s, p, hh)
returns a handlerh
such thath(prec, args)
formats args according tohh
and then prefixes this box bybox s
. Outer parentheses are added ifp < prec
.
- prime: Integer -> (Integer, List OutputForm) -> OutputBox
prime(p)
returns a handler that treats the typesetting of primes. Note that differentiate(a, 3) gives the followings
-expression in OutputForm: (PRIME a “,,,”) whereas differentiate(a+b, 4) gives: (PRIME (+ ab
) (PAREN “iv”)). the precedencep1
. Outer parentheses are added ifp < prec
. See also the auxiliary functionnumberOfPrimes
.
- product: Integer -> (Integer, List OutputForm) -> OutputBox
product(p)
returns a handlerh
such thath(prec, args)
formats a product with product sign and respective limits. Outer parentheses are added ifp < prec
.
- scripts: Integer -> (Integer, List OutputForm) -> OutputBox
Formats super- and subscripts also presuper and presub.
scripts(p)
returns a handlerh
such thath(prec, args)
formats the first argument with respect to the precedencep
. The other arguments are interpreted as subscript, superscript, presuperscript, and presubscript (in this order). Outer parentheses are added ifp < prec
.
- slash: (Integer, (Integer, List OutputForm) -> OutputBox, (Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
Format a fraction linearly.
slash(p, h1, h2)
returns a handlerh
such thath(prec, args)
formats the first argument according toh1
and the second argument byh2
. Outer parentheses are added ifp < prec
.
- subscript: Integer -> (Integer, List OutputForm) -> OutputBox
subscript(p)
returns a handler such thatsubscript(p)(prec, args)
formats the first argument with respect to the precedencep
. The other arguments are formatted without parentheses and interpreted as subscripts separated by commas. Outer parentheses are added ifp < prec
.
- sum: Integer -> (Integer, List OutputForm) -> OutputBox
sum(p)
returns a handlerh
such thath(prec, args)
formats a sum expression with summation sign and respective limits. Outer parentheses are added ifp < prec
.
- theMap: (Integer, List OutputForm) -> OutputBox
theMap
is a special handler to format a function.
- vconcat: ((Integer, List OutputForm) -> OutputBox) -> (Integer, List OutputForm) -> OutputBox
vconcat(hh)
returns a handlerh
such thath(prec, args)
formats args according tohh
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: (Integer, List OutputForm) -> OutputBox
zag
is a handler such thatzag(prec, args)
formats one part of a continued fraction.