StyleEvaluator has run and performs grouping operations
on the FlowTokens to convert them to a more tree-like structure that is easier to handle.
Once this has run, all BraceContainerToken tokens present in PARAGRAPH mode will have
been unwrapped or flattened. They are however kept in MATH and LR mode as they can be used for
implicit brackets. (Unwinding of redundantly nested containers is done in all cases, though.)
Many other types of tokens, such as the "new paragraph" or "new list item" token will have been removed, with the surrounding content grouped accordingly.
LaTeXTokeniser, StyleEvaluator, StyleRebuilder, SnuggleSession#parseInput(uk.ac.ed.ph.snuggletex.SnuggleInput)
| Modifier and Type | Field and Description |
|---|---|
| private final SessionContext |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private CommandToken | Returns: null if the builder is empty, otherwise groupedCommandTokenUseful helper. |
| private ErrorToken | |
| private void | fencePairedParentheses(Token parentToken, List<FlowToken> tokens)
This looks for an outermost pairs of \left and \right and converts them to a more tree-like fence token. |
| private void | fixLeadingNegativeNumber(List<FlowToken> tokens)
Converts leading occurrences of '-' followed by a |
| private void | fixListEnvironmentContent(EnvironmentToken environmentToken)
Helper to fix the representation of a list environment. |
| private void | |
| private void | |
| private void | fixSubscriptAndSuperscripts(Token parentToken, List<FlowToken> tokens)
We'll look for any occurrences of T1_T2[^T3] or T1^T2[_T3], where [..] denotes "optional". |
| private void | fixTabularEnvironmentContent(EnvironmentToken environmentToken)
Helper to fix the content of tabular environments to make it more clearly demarcated as rows and columns. |
| public void | |
| private void | |
| private void | inferParagraphs(List<FlowToken> tokens)
Infers explicit paragraphs by searching for the traditional LaTeX
|
| private void | inferParenthesisFences(Token parentToken, List<FlowToken> tokens)
This attempts to group (not necessarily matching) pairs of open and close brackets into a
corresponding |
| private void | |
| private void | replaceTokens(List<FlowToken> tokens, final int startIndex, final int endIndex, FlowToken replacementToken)
Replaces elements in the tokens List with the given replacement |
| private void | |
| private void | stripRedundantWhitespaceTokens(List<FlowToken> tokens)
Strips out redundant whitespace text tokens at the start and end of a List of siblings and between a pair of "block" tokens. |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void | |
| private void |
| sessionContext | back to summary |
|---|---|
| private final SessionContext sessionContext | |
| TokenFixer | back to summary |
|---|---|
| public TokenFixer(final SessionContext sessionContext) | |
| buildGroupedCommandToken | back to summary |
|---|---|
| private CommandToken buildGroupedCommandToken(final Token parentToken, final BuiltinCommand command, final List<? extends FlowToken> itemBuilder, final ComputedStyle computedStyle) Useful helper. Takes a "builder" that has been accumulating tokens. Groups all tokens
into a An empty group is legal and will result in a "fake" empty token assuming the same Slice and LaTeXMode as parentToken.
| |
| createError | back to summary |
|---|---|
| private ErrorToken createError(final FlowToken token, final CoreErrorCode errorCode, final Object... arguments) throws SnuggleParseException | |
| fencePairedParentheses | back to summary |
|---|---|
| private void fencePairedParentheses(Token parentToken, List<FlowToken> tokens) throws SnuggleParseException This looks for an outermost pairs of \left and \right and converts them to a more tree-like fence token. Mismatched pairs will cause an error, as they do in LaTeX.
| |
| fixLeadingNegativeNumber | back to summary |
|---|---|
| private void fixLeadingNegativeNumber(List<FlowToken> tokens) Converts leading occurrences of '-' followed by a | |
| fixListEnvironmentContent | back to summary |
|---|---|
| private void fixListEnvironmentContent(EnvironmentToken environmentToken) throws SnuggleParseException Helper to fix the representation of a list environment.
The original content should be of the form:
\item ..... \item ..... \item ......
(and maybe include | |
| fixOverInstances | back to summary |
|---|---|
| private void fixOverInstances(Token parentToken, List<FlowToken> tokens) throws SnuggleParseException This handles the old-fashioned "... \over ..." by refactoring the tokens into a \frac{...}{...}. As with LaTeX, we only allow one \over in a single level. | |
| fixPrimes | back to summary |
|---|---|
| private void fixPrimes(List<FlowToken> tokens) Hunts through tokens for occurrences of primes used as f', which are converted to a superscript by binding to the preceding token | |
| fixSubscriptAndSuperscripts | back to summary |
|---|---|
| private void fixSubscriptAndSuperscripts(Token parentToken, List<FlowToken> tokens) throws SnuggleParseException We'll look for any occurrences of T1_T2[^T3] or T1^T2[_T3], where [..] denotes "optional". If found, we'll replace with the more tree-like equivalents: \msub{T1}{T2} \msup{T1}{T2} \msubsup{T1}{T2}{T3} which will be easier to handle later on. | |
| fixTabularEnvironmentContent | back to summary |
|---|---|
| private void fixTabularEnvironmentContent(EnvironmentToken environmentToken) throws SnuggleParseException Helper to fix the content of tabular environments to make it more clearly demarcated
as rows and columns. This kills off instances of | |
| fixTokenTree | back to summary |
|---|---|
| public void fixTokenTree(RootToken rootToken) throws SnuggleParseException | |
| flattenBraceContainers | back to summary |
|---|---|
| private void flattenBraceContainers(List<FlowToken> tokens) | |
| inferParagraphs | back to summary |
|---|---|
| private void inferParagraphs(List<FlowToken> tokens) Infers explicit paragraphs by searching for the traditional LaTeX
| |
| inferParenthesisFences | back to summary |
|---|---|
| private void inferParenthesisFences(Token parentToken, List<FlowToken> tokens) This attempts to group (not necessarily matching) pairs of open and close brackets into a
corresponding It also handles brackets which are not correctly nested, using fake empty opener/closer delimiters at the start/end of the group as required.
Note that this means that while $[1,2)$ will successfully be matched, the notation
$[1,2[$ will *not* be considered matched, even though it is common in subjects like
Mathematical Analysis. To get the correct semantics here, you must use
$\left[1,2\right[$ and let | |
| replaceToken | back to summary |
|---|---|
| private void replaceToken(List<FlowToken> tokens, final int index, FlowToken replacementToken) | |
| replaceTokens | back to summary |
|---|---|
| private void replaceTokens(List<FlowToken> tokens, final int startIndex, final int endIndex, FlowToken replacementToken) Replaces elements in the tokens List with the given replacement The computed style of the replacement token is set to be that of the first token it replaces. | |
| stripBlocks | back to summary |
|---|---|
| private void stripBlocks(List<FlowToken> tokens) throws SnuggleParseException LR Mode doesn't let "block" stuff do its normal thing. We strip out any "new paragraph" markers and fail on any other kind of block tokens. | |
| stripRedundantWhitespaceTokens | back to summary |
|---|---|
| private void stripRedundantWhitespaceTokens(List<FlowToken> tokens) Strips out redundant whitespace text tokens at the start and end of a List of siblings and between a pair of "block" tokens. | |
| visitChildren | back to summary |
|---|---|
| private void visitChildren(List<FlowToken> tokens) throws SnuggleParseException | |
| visitCommand | back to summary |
|---|---|
| private void visitCommand(CommandToken commandToken) throws SnuggleParseException | |
| visitContainerContent | back to summary |
|---|---|
| private void visitContainerContent(ArgumentContainerToken parent) throws SnuggleParseException | |
| visitEnvironment | back to summary |
|---|---|
| private void visitEnvironment(EnvironmentToken environmentToken) throws SnuggleParseException | |
| visitSiblings | back to summary |
|---|---|
| private void visitSiblings(Token parent, List<FlowToken> content) throws SnuggleParseException | |
| visitSiblingsLRMode | back to summary |
|---|---|
| private void visitSiblingsLRMode(List<FlowToken> tokens) throws SnuggleParseException | |
| visitSiblingsMathMode | back to summary |
|---|---|
| private void visitSiblingsMathMode(Token parentToken, List<FlowToken> tokens) throws SnuggleParseException | |
| visitSiblingsParagraphMode | back to summary |
|---|---|
| private void visitSiblingsParagraphMode(List<FlowToken> tokens) throws SnuggleParseException | |
| visitToken | back to summary |
|---|---|
| private void visitToken(Token startToken) throws SnuggleParseException | |