Fork me on GitHub

Context

Context

new Context()private

This class contains the rendering context of the current parse level.

It also holds information about the parent context to handle scaling adjustments.

When a new scope is entered, a clone of the context is created with .clone() or .cloneWith() so that any further changes remain local to the scope. Other functions creating a clone include mathstyle(), fontFamily(), sup(), sub(), cramp(), etc...

A scope is defined by:

  • an explicit group enclosed in braces {...}
  • a semi-simple group enclosed in \bgroup...\endgroup
  • an environment delimited by \begin{<envname>}...\end{<envname>}
Properties
mathstyle string

'text' (aka 'inline'), 'display', 'script' or 'scriptscript'

color string
backgroundcolor string
size number
phantom boolean
font string
generateID boolean

If true, unique IDs should be generated for each span so they can be tracked by to an atom. Can also be an object with a seed field to generate a specific range of IDs. Optionally, if a groupNumbers property is set to true, an additional span will enclose strings of digits. This is used by read aloud to properly pronounce (and highlight) numbers in expressions.

isSelected boolean

If true, items rendered in this context should be rendered in a selected state

parentMathstyle string
parentSize number
macros object

A macros dictionary

Source

Methods

clone()Contextprivate

Returns a new context with the same properties as 'this'.

Context   
Source

cloneWith(property: string, value: *)Contextprivate

Create a new context, identical to this object, except for the given property/value pair.

property string
value *
Context   
Source

getBackgroundColor() → stringprivate

Gets the CSS background color in effect

string   

An hexadecimal color string, e.g. "#cd0030", or 'transparent'

Source

getColor() → stringprivate

Gets the CSS (foreground) color in effect

string   

An hexadecimal color string, e.g. "#cd0030", or 'transparent'

Source

setMathstyle(value: string)private

Change the mathstyle of this context

value string

'auto' to indicate that the mathstyle should in fact not be changed. This is used when specifying the mathstyle for some environments.

Source

withMathstyle(value: string)private

Return a clone context with the specified mathstyle

value string
Source