Add inline box raise and makebox alignment
This commit is contained in:
1 parent
337eaa1778
commit
32b0064e5f
11 files changed
+425
-73
No files matched your search
@@ -3,8 +3,9 @@ use std::collections::{HashMap, VecDeque};
|
||||
use crate::{
|
||||
TeXGlue,
|
||||
document::{
|
||||
Block, ColumnAlignment, DocumentModel, EquationNumber, InlineBox, ListBlock, ListItem,
|
||||
PageMargins, PageSize, ParsedDocument, RuleBox, Run, UnresolvedReference,
|
||||
Block, ColumnAlignment, DocumentModel, EquationNumber, InlineBox, InlineBoxAlign,
|
||||
ListBlock, ListItem, PageMargins, PageSize, ParsedDocument, RuleBox, Run,
|
||||
UnresolvedReference,
|
||||
},
|
||||
expanded,
|
||||
math_expr::*,
|
||||
@@ -374,6 +375,13 @@ fn consume_environment_preamble(
|
||||
start_index
|
||||
}
|
||||
|
||||
struct InlineBoxSpec {
|
||||
runs: Vec<Run>,
|
||||
width: Option<common::Scaled>,
|
||||
align: InlineBoxAlign,
|
||||
raise: common::Scaled,
|
||||
}
|
||||
|
||||
struct Parser {
|
||||
document: DocumentModel,
|
||||
paragraph: Vec<Run>,
|
||||
@@ -404,7 +412,7 @@ struct Parser {
|
||||
framed_box: Option<Vec<Run>>,
|
||||
box_frame: bool,
|
||||
box_width: Option<common::Scaled>,
|
||||
inline_boxes: Vec<Vec<Run>>,
|
||||
inline_boxes: Vec<InlineBoxSpec>,
|
||||
centered: Option<Vec<Run>>,
|
||||
current_source: Option<SourceLocation>,
|
||||
paragraph_source: Option<SourceLocation>,
|
||||
@@ -681,12 +689,21 @@ impl Parser {
|
||||
self.document.show_title = true;
|
||||
self.suppress_indent = true;
|
||||
}
|
||||
expanded::FrontendEventKind::InlineBoxStart => {
|
||||
self.inline_boxes.push(Vec::new());
|
||||
expanded::FrontendEventKind::InlineBoxStart {
|
||||
width,
|
||||
align,
|
||||
raise,
|
||||
} => {
|
||||
self.inline_boxes.push(InlineBoxSpec {
|
||||
runs: Vec::new(),
|
||||
width: *width,
|
||||
align: *align,
|
||||
raise: *raise,
|
||||
});
|
||||
}
|
||||
expanded::FrontendEventKind::InlineBoxEnd => {
|
||||
if let Some(mut runs) = self.inline_boxes.pop() {
|
||||
trim_run_end(&mut runs);
|
||||
if let Some(mut spec) = self.inline_boxes.pop() {
|
||||
trim_run_end(&mut spec.runs);
|
||||
let run = Run {
|
||||
text: String::new(),
|
||||
math: None,
|
||||
@@ -694,7 +711,12 @@ impl Parser {
|
||||
glue: None,
|
||||
penalty: None,
|
||||
rule: None,
|
||||
box_run: Some(InlineBox { runs }),
|
||||
box_run: Some(InlineBox {
|
||||
runs: spec.runs,
|
||||
width: spec.width,
|
||||
align: spec.align,
|
||||
raise: spec.raise,
|
||||
}),
|
||||
unresolved_reference: None,
|
||||
bold: false,
|
||||
italic: false,
|
||||
@@ -704,6 +726,8 @@ impl Parser {
|
||||
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
|
||||
y_offset: None,
|
||||
};
|
||||
self.target_runs().push(run);
|
||||
}
|
||||
@@ -973,6 +997,8 @@ impl Parser {
|
||||
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
|
||||
y_offset: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1093,6 +1119,8 @@ impl Parser {
|
||||
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
|
||||
y_offset: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1126,6 +1154,8 @@ impl Parser {
|
||||
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
|
||||
y_offset: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1164,6 +1194,8 @@ impl Parser {
|
||||
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
|
||||
y_offset: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1212,6 +1244,8 @@ impl Parser {
|
||||
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
|
||||
y_offset: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1231,8 +1265,8 @@ impl Parser {
|
||||
if paragraph_target {
|
||||
self.begin_paragraph_if_needed();
|
||||
}
|
||||
if let Some(runs) = self.inline_boxes.last_mut() {
|
||||
runs
|
||||
if let Some(spec) = self.inline_boxes.last_mut() {
|
||||
&mut spec.runs
|
||||
} else if let Some(runs) = &mut self.centered {
|
||||
runs
|
||||
} else if let Some(runs) = &mut self.framed_box {
|
||||
@@ -1326,6 +1360,8 @@ impl Parser {
|
||||
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
|
||||
y_offset: None,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1652,6 +1688,7 @@ fn indent_run(indent: common::Scaled) -> Run {
|
||||
monospace: false,
|
||||
sans: false,
|
||||
small_caps: false,
|
||||
y_offset: None,
|
||||
paragraph_indent: true,
|
||||
}
|
||||
}
|
||||
@@ -1718,6 +1755,8 @@ fn append_run(
|
||||
sans,
|
||||
small_caps,
|
||||
paragraph_indent: false,
|
||||
|
||||
y_offset: None,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user