Accept tfrac, dfrac and cfrac as fraction aliases
This commit is contained in:
1 parent
4de329c327
commit
ab35e280f1
1 file changed
+12
-1
@@ -588,7 +588,7 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
|
|||||||
}
|
}
|
||||||
parse_atom(chars, after)
|
parse_atom(chars, after)
|
||||||
}
|
}
|
||||||
"frac" => {
|
"frac" | "tfrac" | "dfrac" | "cfrac" => {
|
||||||
let (numerator, after) = parse_atom(chars, next);
|
let (numerator, after) = parse_atom(chars, next);
|
||||||
let (denominator, after) = parse_atom(chars, after);
|
let (denominator, after) = parse_atom(chars, after);
|
||||||
(MathAtom::fraction(numerator, denominator), after)
|
(MathAtom::fraction(numerator, denominator), after)
|
||||||
@@ -1247,6 +1247,17 @@ mod tests {
|
|||||||
assert_eq!(under.height, plain.height);
|
assert_eq!(under.height, plain.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn fraction_style_aliases_match_frac() {
|
||||||
|
let font = Cmr10Metrics::default();
|
||||||
|
let plain = layout_math(&parse_math(r"\frac{a}{b}"), &font);
|
||||||
|
for command in ["tfrac", "dfrac", "cfrac"] {
|
||||||
|
let source = format!(r"\{command}{{a}}{{b}}");
|
||||||
|
let boxed = layout_math(&parse_math(&source), &font);
|
||||||
|
assert_eq!(plain.width, boxed.width);
|
||||||
|
assert_eq!(plain.height, boxed.height);
|
||||||
|
}
|
||||||
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn math_spacing_commands_have_expected_widths() {
|
fn math_spacing_commands_have_expected_widths() {
|
||||||
let font = Cmr10Metrics::default();
|
let font = Cmr10Metrics::default();
|
||||||
|
|||||||
Reference in new issue
Block a user