Keep inline math inside styled runs
This commit is contained in:
1 parent
c6860b7b4a
commit
6aa9d70a49
4 files changed
+37
-4
No files matched your search
@@ -6305,6 +6305,39 @@ A definition.
|
||||
assert_eq!(backslashes, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inline_math_inside_styled_runs_keeps_both_faces() {
|
||||
let blocks = paragraphs("\\textbf{Value $x$}").expect("paragraphs");
|
||||
let document = build_document(&blocks, &PageGeometry::default());
|
||||
let paragraph = match &document.units[0].items[0] {
|
||||
VerticalItem::Paragraph(paragraph) => paragraph,
|
||||
_ => panic!("expected a paragraph unit"),
|
||||
};
|
||||
let boxes: Vec<_> = paragraph
|
||||
.lines
|
||||
.iter()
|
||||
.flatten()
|
||||
.filter_map(|item| match item {
|
||||
texrra_tex_core::paragraph::HorizontalItem::Box(box_) => Some(box_),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert!(
|
||||
boxes.iter().any(|box_| box_.math.is_some()),
|
||||
"the math run keeps its math box"
|
||||
);
|
||||
assert!(
|
||||
boxes
|
||||
.iter()
|
||||
.any(|box_| box_.font == Some(ParagraphFont::Bold) && box_.math.is_none()),
|
||||
"the surrounding text keeps its bold face"
|
||||
);
|
||||
assert!(
|
||||
boxes.iter().all(|box_| box_.character != Some('$')),
|
||||
"math delimiters are consumed"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inline_math_stays_literal_in_sized_paragraphs() {
|
||||
let blocks = paragraphs("\\large Value $x$ tail.").expect("paragraphs");
|
||||
|
||||
Reference in new issue
Block a user