Add dot and check accent commands
This commit is contained in:
1 parent
dc8282f707
commit
9690dbdbed
1 file changed
+26
@@ -534,6 +534,17 @@ fn parse_sequence(
|
||||
(MathAtom::Row(atoms), index)
|
||||
}
|
||||
|
||||
fn accent_atom(chars: &[char], next: usize, accent: char) -> (MathAtom, usize) {
|
||||
let (base, after) = parse_atom(chars, next);
|
||||
(
|
||||
MathAtom::Accent {
|
||||
accent,
|
||||
base: Box::new(base),
|
||||
},
|
||||
after,
|
||||
)
|
||||
}
|
||||
|
||||
fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
|
||||
let mut index = index;
|
||||
while chars.get(index) == Some(&'\u{0}') {
|
||||
@@ -802,6 +813,12 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
|
||||
after,
|
||||
)
|
||||
}
|
||||
"dot" => accent_atom(chars, next, '\u{0307}'),
|
||||
"ddot" => accent_atom(chars, next, '\u{0308}'),
|
||||
"check" => accent_atom(chars, next, '\u{030C}'),
|
||||
"breve" => accent_atom(chars, next, '\u{0306}'),
|
||||
"acute" => accent_atom(chars, next, '\u{0301}'),
|
||||
"grave" => accent_atom(chars, next, '\u{0300}'),
|
||||
"bar" | "overline" => {
|
||||
let (base, after) = parse_atom(chars, next);
|
||||
(
|
||||
@@ -1288,6 +1305,15 @@ mod tests {
|
||||
assert_eq!(plain.height, numbered.height);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dot_and_check_accents_raise_the_math_box() {
|
||||
let font = Cmr10Metrics::default();
|
||||
for command in [r"\dot{x}", r"\ddot{x}", r"\check{x}", r"\breve{x}"] {
|
||||
let accented = layout_math(&parse_math(command), &font);
|
||||
let plain = layout_math(&parse_math("x"), &font);
|
||||
assert!(accented.height > plain.height);
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn fence_delimiters_have_widths() {
|
||||
let font = Cmr10Metrics::default();
|
||||
|
||||
Reference in new issue
Block a user