List of (fixed) Tokens and builds a (raw) XHTML + MathML
DOM tree branch from them.
SnuggleSession#buildDOMSubtree(Element, DOMOutputOptions) and friends.
An instance of this class is intended to be used once and then discarded so can be stateful.
This contains a number of callbacks that CommandHandlers and EnvironmentHandlers
can use to do their magic.
TokenFixer, DOMBuildingController
| Modifier and Type | Class and Description |
|---|---|
| public static interface | DOMBuilder.
Internal callback interface that specifies how to build the real content of a MathML element. |
| public static enum | DOMBuilder.
Trivial enumeration to keep track of where we are in the outgoing DOM. |
| Modifier and Type | Field and Description |
|---|---|
| private final Element | buildRootElement
|
| private Properties | currentInlineCSSProperties
CSS Properties, used for inlining and created lazily as required |
| private Element | |
| private DOMBuilder. | |
| private final DOMBuilder. | defaultMathContentBuilderCallback
Trivial instance of |
| private final Document | document
|
| private final String | |
| private final ArrayListStack | mathVariantMapStack
Stack of active |
| private final DOMOutputOptions | options
Build options specified by user |
| private final SessionContext | sessionContext
Underlying |
| private final ArrayListStack | |
| private final VariableManager | variableManager
Helper to manage variables |
| Access | Constructor and Description |
|---|---|
| public | DOMBuilder(final SessionContext sessionContext, final Element buildRootElement, final DOMOutputOptions options)
|
| Modifier and Type | Method and Description |
|---|---|
| public Element | |
| public void | |
| public Element | |
| public Element | appendMathMLIdentifierElement(Element parentElement, String name)
Creates a MathML identifier element, which may either be a single character or multiple characters (e.g. "sin"). |
| public Element | |
| public Element | |
| public Element | |
| public Element | appendMathMLTextElement(Element parentElement, String elementLocalName, String content, boolean trim)
|
| public Element | appendOrThrowError(final Element parentElement, final Token token, final ErrorCode errorCode, final Object... arguments)
|
| public void | |
| public Element | |
| public Node | |
| public Element | |
| public Element | appendXHTMLTextElement(Element parentElement, String elementLocalName, String content, boolean trim)
|
| public void | |
| public void | buildDOMSubtree(final List<FlowToken> fixedTokens)
This is the external entry point used by |
| public void | buildMathElement(final Element parentElement, final Token token, final ArgumentContainerToken mathContentToken, final boolean isDisplayMath)
Builds a MathML math element for the given Token token, using contentToken to provide the content, descending into child Nodes as normal. |
| public void | buildMathElement(final Element parentElement, final Token token, final ArgumentContainerToken mathContentToken, final boolean isDisplayMath, final DOMBuilder.
Builds a MathML math element for the given Token token, using contentToken
to provide the content, using the given |
| private void | |
| public ComputedStyle | |
| public NodeList | |
| public String | extractStringValue(ArgumentContainerToken token)
This "converts" the given token to a String by performing
{ |
| public Element | |
| private Properties | |
| public Document | |
| public ArrayListStack | |
| public DOMOutputOptions | |
| public DOMBuilder. | |
| public SessionContext | |
| public VariableManager | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | handleTokens(Element parentElement, ArgumentContainerToken containerToken, boolean
removes leading whitespace from the first resulting Node if it is a Text Node and
removes trailing whitespace from the last Node if it is a Text Node. trimWhitespace)
|
| public void | handleTokens(Element parentElement, List<FlowToken> siblingTokens, boolean
removes leading whitespace from the first resulting Node if it is a Text Node and
removes trailing whitespace from the last Node if it is a Text Node. trimWhitespace)
|
| public boolean | isBuildingMathMLIsland()
Returns whether or not we're building a MathML island by checking the current
|
| public boolean | isParentElement(final Element parentElement, final String requiredNamespaceUri, final String... requiredLocalNames)
|
| public Element | openStyle(Element parentElement, ComputedStyle newStyle, boolean hasBlockContent, boolean hasEmptyContent)
|
| public URI | |
| public void | |
| public URI | validateURI(final Element parentElement, final Token token, final String rawURI)
Checks the given raw URI to ensure that it is valid, returning a |
| public String | validateXMLId(final Element parentElement, final Token nameToken, final String rawName)
Checks the given XML Name as in |
| public String | validateXMLName(final Element parentElement, final Token nameToken, final String rawName)
Checks the given raw XML Name to ensure that it confirms to the correct syntax, returning it unchanged if successful. |
| buildRootElement | back to summary |
|---|---|
| private final Element buildRootElement
| |
| currentInlineCSSProperties | back to summary |
|---|---|
| private Properties currentInlineCSSProperties CSS Properties, used for inlining and created lazily as required | |
| currentMathOwnerElement | back to summary |
|---|---|
| private Element currentMathOwnerElement | |
| currentOutputContext | back to summary |
|---|---|
| private DOMBuilder. | |
| defaultMathContentBuilderCallback | back to summary |
|---|---|
| private final DOMBuilder. Trivial instance of | |
| document | back to summary |
|---|---|
| private final Document document
| |
| lineSeparator | back to summary |
|---|---|
| private final String lineSeparator | |
| mathVariantMapStack | back to summary |
|---|---|
| private final ArrayListStack<MathVariantMap> mathVariantMapStack Stack of active | |
| options | back to summary |
|---|---|
| private final DOMOutputOptions options Build options specified by user | |
| sessionContext | back to summary |
|---|---|
| private final SessionContext sessionContext Underlying | |
| textStyleStack | back to summary |
|---|---|
| private final ArrayListStack<ComputedStyle> textStyleStack | |
| variableManager | back to summary |
|---|---|
| private final VariableManager variableManager Helper to manage variables | |
| DOMBuilder | back to summary |
|---|---|
| public DOMBuilder(final SessionContext sessionContext, final Element buildRootElement, final DOMOutputOptions options) | |
| appendErrorElement | back to summary |
|---|---|
| public Element appendErrorElement(final Element parentElement, final ErrorToken errorToken) | |
| appendMathCharacter | back to summary |
|---|---|
| public void appendMathCharacter(Element parentElement, MathCharacter character) | |
| appendMathMLElement | back to summary |
|---|---|
| public Element appendMathMLElement(Element parentElement, String elementLocalName) | |
| appendMathMLIdentifierElement | back to summary |
|---|---|
| public Element appendMathMLIdentifierElement(Element parentElement, String name) Creates a MathML identifier element, which may either be a single character or multiple characters (e.g. "sin"). The single-character case is interesting if we are currently applying a "mathvariant" in that it may or may not then be mapped into a corresponding target character. | |
| appendMathMLNumberElement | back to summary |
|---|---|
| public Element appendMathMLNumberElement(Element parentElement, String number) | |
| appendMathMLOperatorElement | back to summary |
|---|---|
| public Element appendMathMLOperatorElement(Element parentElement, String content) | |
| appendMathMLSpace | back to summary |
|---|---|
| public Element appendMathMLSpace(Element parentElement, String width) | |
| appendMathMLTextElement | back to summary |
|---|---|
| public Element appendMathMLTextElement(Element parentElement, String elementLocalName, String content, boolean trim) | |
| appendOrThrowError | back to summary |
|---|---|
| public Element appendOrThrowError(final Element parentElement, final Token token, final ErrorCode errorCode, final Object... arguments) throws SnuggleParseException | |
| appendSimpleMathElement | back to summary |
|---|---|
| public void appendSimpleMathElement(Element parentElement, Token token) | |
| appendSnuggleElement | back to summary |
|---|---|
| public Element appendSnuggleElement(Element parentElement, String elementLocalName) | |
| appendTextNode | back to summary |
|---|---|
| public Node appendTextNode(Element parentElement, String content, boolean trim) | |
| appendXHTMLElement | back to summary |
|---|---|
| public Element appendXHTMLElement(Element parentElement, String elementLocalName) | |
| appendXHTMLTextElement | back to summary |
|---|---|
| public Element appendXHTMLTextElement(Element parentElement, String elementLocalName, String content, boolean trim) | |
| applyCSSStyle | back to summary |
|---|---|
| public void applyCSSStyle(Element xhtmlElement, String... cssClassNames) | |
| buildDOMSubtree | back to summary |
|---|---|
| public void buildDOMSubtree(final List<FlowToken> fixedTokens) throws SnuggleParseException This is the external entry point used by | |
| buildMathElement | back to summary |
|---|---|
| public void buildMathElement(final Element parentElement, final Token token, final ArgumentContainerToken mathContentToken, final boolean isDisplayMath) throws SnuggleParseException Builds a MathML math element for the given Token token, using contentToken to provide the content, descending into child Nodes as normal. | |
| buildMathElement | back to summary |
|---|---|
| public void buildMathElement(final Element parentElement, final Token token, final ArgumentContainerToken mathContentToken, final boolean isDisplayMath, final DOMBuilder. Builds a MathML math element for the given Token token, using contentToken
to provide the content, using the given
This is useful for things like | |
| buildStringValue | back to summary |
|---|---|
| private void buildStringValue(StringBuilder resultBuilder, NodeList nodes) | |
| closeStyle | back to summary |
|---|---|
| public ComputedStyle closeStyle() | |
| extractNodeListValue | back to summary |
|---|---|
| public NodeList extractNodeListValue(ArgumentContainerToken token) throws SnuggleParseException | |
| extractStringValue | back to summary |
|---|---|
| public String extractStringValue(ArgumentContainerToken token) throws SnuggleParseException This "converts" the given token to a String by performing
{ | |
| findNearestXHTMLAncestorOrSelf | back to summary |
|---|---|
| public Element findNearestXHTMLAncestorOrSelf(final Element element) | |
| getCurrentInlineCSSProperties | back to summary |
|---|---|
| private Properties getCurrentInlineCSSProperties() | |
| getDocument | back to summary |
|---|---|
| public Document getDocument() Gets at the underlying DOM Document. Use this to do exotic things not covered elsewhere. To append XHTML and/or MathML elements, you should use the alternatives methods listed here to ensure correct namespace handling. | |
| getMathVariantMapStack | back to summary |
|---|---|
| public ArrayListStack | |
| getOptions | back to summary |
|---|---|
| public DOMOutputOptions getOptions() | |
| getOutputContext | back to summary |
|---|---|
| public DOMBuilder. | |
| getSessionContext | back to summary |
|---|---|
| public SessionContext getSessionContext() | |
| getVariableManager | back to summary |
|---|---|
| public VariableManager getVariableManager() | |
| handleMathTokensAsSingleElement | back to summary |
|---|---|
| public void handleMathTokensAsSingleElement(Element parentElement, ArgumentContainerToken containerToken) throws SnuggleParseException | |
| handleMathTokensAsSingleElement | back to summary |
|---|---|
| public void handleMathTokensAsSingleElement(Element parentElement, List<FlowToken> tokens) throws SnuggleParseException | |
| handleTextToken | back to summary |
|---|---|
| public void handleTextToken(Element parentElement, SimpleToken textToken) | |
| handleToken | back to summary |
|---|---|
| public void handleToken(Element parentElement, FlowToken token) throws SnuggleParseException Creates a single Node from the given token. If the token is a container then it will be wrapped into a container element if required, depending on context. Example: \msub{1+2}{3-\mrow{4*5}} -> <msup<mrow>...</mrow><mrow>...</mrow></msup> | |
| handleTokens | back to summary |
|---|---|
public void handleTokens(Element parentElement, ArgumentContainerToken containerToken, boolean trimWhitespace) throws SnuggleParseException
| |
| handleTokens | back to summary |
|---|---|
public void handleTokens(Element parentElement, List<FlowToken> siblingTokens, boolean trimWhitespace) throws SnuggleParseException
| |
| isBuildingMathMLIsland | back to summary |
|---|---|
| public boolean isBuildingMathMLIsland() Returns whether or not we're building a MathML island by checking the current
| |
| isParentElement | back to summary |
|---|---|
| public boolean isParentElement(final Element parentElement, final String requiredNamespaceUri, final String... requiredLocalNames) | |
| openStyle | back to summary |
|---|---|
| public Element openStyle(Element parentElement, ComputedStyle newStyle, boolean hasBlockContent, boolean hasEmptyContent) | |
| resolveLink | back to summary |
|---|---|
| public URI resolveLink(final Element parentElement, final Token token, final String rawHref) throws SnuggleParseException | |
| setOutputContext | back to summary |
|---|---|
| public void setOutputContext(Element parentElement, DOMBuilder. | |
| validateURI | back to summary |
|---|---|
| public URI validateURI(final Element parentElement, final Token token, final String rawURI) throws SnuggleParseException Checks the given raw URI to ensure that it is valid, returning a | |
| validateXMLId | back to summary |
|---|---|
| public String validateXMLId(final Element parentElement, final Token nameToken, final String rawName) throws SnuggleParseException Checks the given XML Name as in | |
| validateXMLName | back to summary |
|---|---|
| public String validateXMLName(final Element parentElement, final Token nameToken, final String rawName) throws SnuggleParseException Checks the given raw XML Name to ensure that it confirms to the correct syntax, returning
it unchanged if successful. If not valid, the | |
| Modifier and Type | Method and Description |
|---|---|
| public void | buildMathElementContent(final Element contentContainerElement, final ArgumentContainerToken mathContentToken, final boolean isAnnotated)
|
| buildMathElementContent | back to summary |
|---|---|
| public void buildMathElementContent(final Element contentContainerElement, final ArgumentContainerToken mathContentToken, final boolean isAnnotated) throws SnuggleParseException | |
DOMBuilder#getOutputContext(), DOMBuilder#setOutputContext(Element, OutputContext)
to manage the current status.
| Modifier and Type | Field and Description |
|---|---|
| public static final DOMBuilder. | |
| public static final DOMBuilder. | |
| public static final DOMBuilder. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static DOMBuilder. | |
| public static DOMBuilder. |
| MATHML_BLOCK | back to summary |
|---|---|
| public static final DOMBuilder. | |
| MATHML_INLINE | back to summary |
|---|---|
| public static final DOMBuilder. | |
| XHTML | back to summary |
|---|---|
| public static final DOMBuilder. | |
| OutputContext | back to summary |
|---|---|
| private OutputContext() | |
| valueOf | back to summary |
|---|---|
| public static DOMBuilder. | |
| values | back to summary |
|---|---|
| public static DOMBuilder. | |