DollarMathCloser class
Finds the closing $ of single-dollar maths, for one text.
Pandoc's rule, which is what keeps prices out of maths: the opening $
must have a non-space right after it, and the closing one a non-space right
before it and no digit right after. $x$ and $\frac{a}{b}$ are maths;
$5 and $10 has no closer, so both dollars stay prose. An escaped \$ and
either half of a $$ never close. With sameLine the closer must be on
the opener's line.
One addition: an opener followed by a digit closes only before the next
whitespace. $2^{10}$ is maths, but cost $5 and $x^2$ is the price $5
followed by the formula x^2 — Pandoc alone reads 5 and $x^2 as one
formula. The streaming reveal never opens at a digit, so the two agree on
every price.
The one rule the parser, the $ rewrite and the streaming reveal share.
Openers must be asked about left to right: a search that fails is
remembered, because every later opener (on the same line, with
sameLine) would fail too. Without that a line of $a repeated costs a
full scan per dollar.
Constructors
- DollarMathCloser(String text, {bool sameLine = false})
Properties
Methods
-
find(
int i) → int -
The closer for the
$ati, or -1. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited