Jump to navigation

Namespace: display

Numbas.jme.display

Members

(static) JMEifier

An object which can convert a JME tree into a string of JME code.

Source:

(static) Texifier

Convert a JME tree to TeX.

Source:

(static) jmeFunctions :function

Define how to render function in JME, for special cases when the normal rendering f(...) isn't right.

Type:
Properties:
Name Type Description
dict function
fact function
listval function
Source:

(static) specialNames :Object.<string>

Names with special renderings.

Type:
Source:

(static) texNameAnnotations

Dictionary of functions to convert specific name annotations to TeX.

Properties:
Name Type Description
verbatim
op
vector
unit
dot
matrix
diff
degrees
bb
complex
imaginary
real
positive
nonnegative
negative
integer
decimal
rational
nonone
nonzero
Source:

(static) texOps :function

Define how to texify each operation and function.

Type:
Properties:
Name Type Description
"#" function
not function
"+u" function
"-u" function
"^" function
"*" function
"/" function
"+" function
"-" function
dot function
cross function
transpose function
".." function
except function
"<" function
">" function
"<=" function
">=" function
"<>" function
"=" function
and function
or function
xor function
implies function
in function
"|" function
decimal function
abs function
sqrt function
exp function
fact function
ceil function
floor function
int function
defint function
diff function
partialdiff function
sub function
sup function
limit function
mod function
perm function
comb function
root function
if function
switch function
gcd function
lcm function
trunc function
fract function
degrees function
radians function
round function
sign function
random function
max function
min function
precround function
siground function
award function
hour24 function
hour function
ampm function
minute function
second function
msecond function
dayofweek function
sin function
cos function
tan function
sec function
cot function
cosec function
arccos function
arcsin function
arctan function
cosh function
sinh function
tanh function
coth function
cosech function
sech function
arcsinh function
arccosh function
arctanh function
ln function
log function
vector function
rowvector function
matrix function
listval function
set function
"`+-" function
"`*/" function
"`|" function
"`&" function
"`!" function
"`where" function
"`@" function
"`?" function
"`*" function
"`+" function
"`:" function
";" function
";=" function
m_uses function
m_type function
m_exactly function
m_commutative function
m_noncommutative function
m_associative function
m_nonassociative function
m_strictplus function
m_gather function
m_nogather function
m_func function
m_op function
m_numeric function
Source:

(static) typeToJME

Dictionary of functions to turn Numbas.jme.types objects into JME strings.

Properties:
Name Type Description
nothing
integer
rational
decimal
number
name
string
html
boolean
range
list
keypair
dict
vector
matrix
function
op
set
expression
lambda
Source:

(static) typeToTeX

Dictionary of functions to turn Numbas.jme.types objects into TeX strings.

Properties:
Name Type Description
nothing
integer
rational
decimal
number
string
boolean
range
list
keypair
dict
vector
matrix
name
op
function
set
expression
lambda
Source:

Methods

(static) exprToLaTeX(expr, ruleset, scope, parseropt) → {TeX}

Convert a JME expression to LaTeX.

Parameters:
Name Type Attributes Default Description
expr JME
ruleset Array.<string> | Numbas.jme.rules.Ruleset

Can be anything accepted by Numbas.jme.display.collectRuleset.

scope Numbas.jme.Scope
parser Numbas.jme.Parser <optional>
Numbas.jme.standardParser
Returns:
Type Description
TeX
Source:

(static) simplify(expr, ruleset, scope, parseropt) → {Numbas.jme.tree}

Simplify a JME expression string according to given ruleset and return it as a syntax tree.

Parameters:
Name Type Attributes Default Description
expr JME
ruleset Array.<string> | Numbas.jme.rules.Ruleset
scope Numbas.jme.Scope
parser Numbas.jme.Parser <optional>
Numbas.jme.standardParser
Returns:
Type Description
Numbas.jme.tree
Source:
See:

(static) simplifyExpression(expr, ruleset, scope) → {JME}

Simplify a JME expression string according to the given ruleset and return it as a JME string.

Parameters:
Name Type Description
expr JME
ruleset Array.<string> | Numbas.jme.rules.Ruleset

Can be anything accepted by Numbas.jme.display.collectRuleset.

scope Numbas.jme.Scope
Returns:
Type Description
JME
Source:
See:

(static) simplifyTree(exprTree, ruleset, scope, allowUnbound) → {Numbas.jme.tree}

Simplify a syntax tree according to the given ruleset.

Parameters:
Name Type Description
exprTree Numbas.jme.tree
ruleset Numbas.jme.rules.Ruleset
scope Numbas.jme.Scope
allowUnbound boolean
Returns:
Type Description
Numbas.jme.tree
Source:
See:

(static) subvars(expr, scope) → {Numbas.jme.tree}

Substitute values into a JME string, and return an expression tree.

Parameters:
Name Type Description
expr JME
scope Numbas.jme.Scope
Returns:
Type Description
Numbas.jme.tree
Source:

(static) texName(tok, longNameMacroopt) → {TeX}

Convert a variable name to TeX.

Parameters:
Name Type Attributes Default Description
tok Numbas.jme.token
longNameMacro function <optional>
texttt

Function which returns TeX for a long name.

Returns:
Type Description
TeX
Source:

(static) texify(tree, settings, scope) → {TeX}

Turn a syntax tree into a TeX string. Data types can be converted to TeX straightforwardly, but operations and functions need a bit more care.

The idea here is that each function and op has a function associated with it which takes a syntax tree with that op at the top and returns the appropriate TeX.

Parameters:
Name Type Description
tree Numbas.jme.tree
settings Numbas.jme.display.displayer_settings
scope Numbas.jme.Scope
Returns:
Type Description
TeX
Source:

(static) treeToJME(tree, settings, scope) → {JME}

Turn a syntax tree back into a JME expression (used when an expression is simplified).

Parameters:
Name Type Description
tree Numbas.jme.tree
settings Numbas.jme.display.jme_display_settings
scope Numbas.jme.Scope
Returns:
Type Description
JME
Source:

(static) treeToLaTeX(tree, ruleset, scope) → {TeX}

Convert a compiled JME expression to LaTeX.

Parameters:
Name Type Description
tree Numbas.jme.tree
ruleset Array.<string> | Numbas.jme.rules.Ruleset

Can be anything accepted by Numbas.jme.display.collectRuleset.

scope Numbas.jme.Scope
Returns:
Type Description
TeX
Source:

Type Definitions

displayer_settings

A dictionary of settings for Numbas.jme.display.texify.

Properties:
Name Type Description
fractionnumbers boolean

Show all numbers as fractions?

rowvector boolean

Display vectors as a horizontal list of components?

alwaystimes boolean

Always show the multiplication symbol between multiplicands?

mixedfractions boolean

Show top-heavy fractions as mixed fractions, e.g. 3 3/4?

flatfractions boolean

Display fractions horizontally?

barematrices boolean

Render matrices without wrapping them in parentheses.

nicenumber boolean

Run numbers through Numbas.math.niceNumber?

noscientificnumbers boolean

If true, don't write numbers in scientific notation.

accuracy number

Accuracy to use when finding rational approximations to numbers. See Numbas.math.rationalApproximation.

timesdot boolean

Use a dot for the multiplication symbol instead of a cross?

timesspace boolean

Use a space for the multiplication symbol instead of a cross?

Source:
See:

jme_display_settings

A dictionary of settings for Numbas.jme.display.treeToJME.

Properties:
Name Type Description
fractionnumbers boolean

Show all numbers as fractions?

niceNumber boolean

Run numbers through Numbas.math.niceNumber?

wrapexpressions boolean

Wrap TExpression tokens in expression("")?

store_precision boolean

Render numbers along with their precision metadata, if any?

ignorestringattributes boolean

Don't wrap strings in functions for attributes like latex() and safe().

matrixcommas boolean

Put commas between cells in matrix rows?

accuracy number

Accuracy to use when finding rational approximations to numbers. See Numbas.math.rationalApproximation.

Source:

special_number_definition

Definition of a number with a special name.

Properties:
Name Type Description
value number
tex TeX

The TeX code for this number.

jme JME

The JME code for this number.

Source:

string_options

Options for rendering a string token.

Properties:
Name Type Description
latex boolean
safe boolean
Source:
See: