Parse over-arrow math accents
This commit is contained in:
1 parent
7802df54a3
commit
cefc3e5289
2 files changed
+31
No files matched your search
@@ -730,6 +730,21 @@ fn parse_atom(chars: &[char], index: usize) -> (MathAtom, usize) {
|
||||
after,
|
||||
)
|
||||
}
|
||||
"overrightarrow" | "overleftarrow" => {
|
||||
let (base, after) = parse_atom(chars, next);
|
||||
let accent = if command == "overrightarrow" {
|
||||
'\u{20D7}'
|
||||
} else {
|
||||
'\u{20D6}'
|
||||
};
|
||||
(
|
||||
MathAtom::Accent {
|
||||
accent,
|
||||
base: Box::new(base),
|
||||
},
|
||||
after,
|
||||
)
|
||||
}
|
||||
"vec" => {
|
||||
let (base, after) = parse_atom(chars, next);
|
||||
(
|
||||
@@ -1000,6 +1015,20 @@ mod tests {
|
||||
assert!(tall.width > plain.width);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn overrightarrow_uses_the_arrow_accent() {
|
||||
let parsed = parse_math(r"\overrightarrow{AB}");
|
||||
let MathAtom::Row(atoms) = parsed else {
|
||||
panic!("expected row")
|
||||
};
|
||||
assert!(matches!(
|
||||
&atoms[0],
|
||||
MathAtom::Accent {
|
||||
accent: '\u{20D7}',
|
||||
..
|
||||
}
|
||||
));
|
||||
}
|
||||
#[test]
|
||||
fn stackrel_places_its_first_argument_above_the_relation() {
|
||||
let font = Cmr10Metrics::default();
|
||||
|
||||
@@ -214,3 +214,5 @@ for a later overlaid slash.
|
||||
`Unit::penalty(id, value)` adds a vertical penalty; values <= -10000 force a page break.
|
||||
|
||||
`\stackrel{top}{base}` shares the `Stack` layout with `\overset`.
|
||||
|
||||
`\overrightarrow`/`\overleftarrow` parse as arrow accents (U+20D7/U+20D6).
|
||||
Reference in new issue
Block a user