-
Notifications
You must be signed in to change notification settings - Fork 22
Public API
TeXZilla.toMathMLString = function(aTeX, aDisplay, aRTL, aThrowExceptionOnError)
converts the TeX string aTeX into a MathML source. The optional boolean aDisplay and aRTL indicates whether the MathML output should be in display mode and in RTL direction respectively. The optional boolean aThrowExceptionOnError indicates whether TeXZilla should throw an exception when parsing fails.
TeXZilla.toMathML = function(aTeX, aDisplay, aRTL, aThrowExceptionOnError)
is the same as TeXZilla.toMathMLString, but returns a MathML DOM element. This requires to have a DOMParser API available (see TeXZilla.setDOMParser below).
TeXZilla.toImage = function(aTeX, aRTL, aRoundToPowerOfTwo, aSize, aDocument)
This function converts the TeX string aTeX into a display MathML element
which is then inserted in the HTML document aDocument
(this parameter is optional and defaults to window.document) for measuring.
Then this MathML element is embedded into a SVG
element via the <foreignObject> element, serialized as a base64 string
which is in turn used as the src attribute value of <img> element.
The function returns the <img> element. The optional boolean parameter aRTL
indicates the directionality of the MathML element. The optional boolean
parameter aRoundToPowerOfTwo indicates whether the size of the images
should be rounded to a power of two and is useful
for use in a WebGL context. Finally aSize indicates the font-size in pixels
of the MathML element and defaults to 64px.
This requires to have a DOMParser API available (see TeXZilla.setDOMParser below) and a HTML document to get the size of the mathematical formula.
This requires TeXZilla >= 0.9.7.
TeXZilla.filterString = function(aString, aThrowExceptionOnError)
applies the stream filter to aString and returns the output string. The optional boolean aThrowExceptionOnError indicates whether TeXZilla should throw an exception when parsing fails.
This requires TeXZilla >= 0.9.7.
TeXZilla.filterElement = function(aElement, aThrowExceptionOnError)
applies the stream filter to each text node inside descendant elements of aElement. The optional boolean aThrowExceptionOnError indicates whether TeXZilla should throw an exception when parsing fails.
This requires to have a DOMParser API available (see TeXZilla.setDOMParser below). This requires TeXZilla >= 0.9.7.
TeXZilla.getTeXSource = function(aMathMLElement)
returns the TeX source attached to aMathMLElement via a semantics annotation or null if none is found. aMathMLElement is either a string or a MathML DOM element. This requires to have a DOMParser API available (see TeXZilla.setDOMParser below).
TeXZilla.setDOMParser = function(aDOMParser)
sets TeXZilla's DOMParser to the DOMParser instance aDOMParser. Note that
TeXZilla tries to automatically initialized its DOMParser to new DOMParser()
and otherwise leave it null.
TeXZilla.setSafeMode = function(aEnable)
enables or disables TeXZilla's safe mode as indicated by the boolean aEnable.
By default safe mode is disabled but if you enable it, MathML features like href
or maction that are known to be usable for XSS injections will be ignored.
This requires TeXZilla >= 0.9.7.
TeXZilla.setItexIdentifierMode = function(aEnable)
enables or disables
itex identifier
mode as indicated by the boolean aEnable.
By this is disabled but if you enable it, a sequence of basic latin letters
(a, b, ... z, A, B, C, ..., Z) such as $pin$ will generate a single MathML
token <mi>pin</mi>. Other letters e.g. Greek or Arabic will still be treated
as individual tokens. This requires TeXZilla >= 0.9.7.