Report active native math alignment and output lists
This commit is contained in:
1 parent
3ed2c2cd54
commit
d02777a1fc
12 files changed
+779
-199
No files matched your search
@@ -30,10 +30,10 @@ struct Cell {
|
||||
}
|
||||
#[derive(Clone)]
|
||||
pub(super) struct AlignmentFrame {
|
||||
horizontal: bool,
|
||||
span: Span,
|
||||
pub(super) horizontal: bool,
|
||||
pub(super) span: Span,
|
||||
spec: PackSpec,
|
||||
depth: usize,
|
||||
pub(super) depth: usize,
|
||||
stage: Stage,
|
||||
templates: Vec<Template>,
|
||||
skips: Vec<Glue>,
|
||||
@@ -43,21 +43,37 @@ pub(super) struct AlignmentFrame {
|
||||
column: usize,
|
||||
first: usize,
|
||||
omitted: bool,
|
||||
terminator: Option<Primitive>,
|
||||
terminator: Option<(Primitive, Span)>,
|
||||
cells: Vec<Cell>,
|
||||
adjustments: super::super::marks::MigratingMaterial,
|
||||
// Maximum natural extent, indexed by (last,first) so each constraint is
|
||||
// visited once when its final column is resolved.
|
||||
extents: std::collections::BTreeMap<(usize, usize), i64>,
|
||||
parent_paragraph: Option<super::super::paragraph::Builder>,
|
||||
parent_vertical: VerticalBuilder,
|
||||
parent_math: Vec<super::super::math::MathBuilder>,
|
||||
parent_display: Option<super::display::DisplayFrame>,
|
||||
pub(super) parent_paragraph: Option<super::super::paragraph::Builder>,
|
||||
pub(super) parent_vertical: VerticalBuilder,
|
||||
pub(super) parent_math: Vec<super::super::math::MathBuilder>,
|
||||
pub(super) parent_display: Option<super::display::DisplayFrame>,
|
||||
parent_balance: i64,
|
||||
row_paragraph: Option<super::super::paragraph::Builder>,
|
||||
row_vertical: VerticalBuilder,
|
||||
pub(super) row_paragraph: Option<super::super::paragraph::Builder>,
|
||||
pub(super) row_vertical: VerticalBuilder,
|
||||
row_span: Option<Span>,
|
||||
pub(super) cell_span: Option<Span>,
|
||||
}
|
||||
impl AlignmentFrame {
|
||||
pub(super) fn activity_row(&self) -> Option<(Span, Vec<super::super::diagnostics::DiagnosticNode>)> {
|
||||
use super::super::diagnostics::{DiagnosticNode, box_view};
|
||||
|
||||
let span = self.row_span?;
|
||||
let tabskip = |value| DiagnosticNode::Glue { value, name: Some(Parameter::Tabskip) };
|
||||
let mut nodes = Vec::with_capacity(1 + 2 * self.cells.len());
|
||||
nodes.push(tabskip(self.skips[0]));
|
||||
for cell in &self.cells {
|
||||
nodes.push(DiagnosticNode::Box(box_view(&cell.node)));
|
||||
nodes.push(tabskip(self.skips[cell.last + 1]));
|
||||
}
|
||||
Some((span, nodes))
|
||||
}
|
||||
|
||||
pub(super) fn collect_statistics(&self, c: &mut super::super::statistics::Collector) {
|
||||
use super::super::statistics::Ownership::Active;
|
||||
for p in [&self.parent_paragraph, &self.row_paragraph]
|
||||
@@ -150,7 +166,7 @@ impl Executor {
|
||||
if frame.stage != Stage::Entry {
|
||||
return self.fail("interwoven native alignment preambles");
|
||||
}
|
||||
frame.terminator = Some(end);
|
||||
frame.terminator = Some((end, token.token.invocation.unwrap_or(token.token.span)));
|
||||
frame.stage = Stage::Suffix;
|
||||
let suffix = if frame.omitted {
|
||||
Vec::new()
|
||||
@@ -238,6 +254,8 @@ impl Executor {
|
||||
parent_balance,
|
||||
row_paragraph: None,
|
||||
row_vertical: VerticalBuilder::default(),
|
||||
row_span: None,
|
||||
cell_span: None,
|
||||
});
|
||||
self.alignment_balance = -1_000_000;
|
||||
if horizontal {
|
||||
@@ -399,18 +417,22 @@ impl Executor {
|
||||
let frame = self.alignments.last_mut().unwrap();
|
||||
frame.column = 0;
|
||||
frame.first = 0;
|
||||
self.begin_alignment_cell(false, files)?;
|
||||
let span = t.token.invocation.unwrap_or(t.token.span);
|
||||
frame.row_span = Some(span);
|
||||
self.begin_alignment_cell(false, span, files)?;
|
||||
self.begin_alignment_template(t)
|
||||
}
|
||||
fn begin_alignment_cell(
|
||||
&mut self,
|
||||
spanning: bool,
|
||||
cell_span: Span,
|
||||
files: &mut impl SourceProvider,
|
||||
) -> Result<(), Error> {
|
||||
if spanning {
|
||||
return Ok(());
|
||||
}
|
||||
let frame = self.alignments.last_mut().unwrap();
|
||||
frame.cell_span = Some(cell_span);
|
||||
frame.row_paragraph = self.paragraph.take();
|
||||
let horizontal = frame.horizontal;
|
||||
frame.row_vertical = self.vertical.enter_nested(horizontal);
|
||||
@@ -447,7 +469,7 @@ impl Executor {
|
||||
return self.fail("unbalanced native alignment entry");
|
||||
}
|
||||
self.finish_text(true)?;
|
||||
let (end, horizontal, span, first, last) = {
|
||||
let ((end, end_span), horizontal, span, first, last) = {
|
||||
let f = self.alignments.last().unwrap();
|
||||
(
|
||||
f.terminator.unwrap(),
|
||||
@@ -510,7 +532,7 @@ impl Executor {
|
||||
}
|
||||
self.alignment_balance = 1_000_000;
|
||||
let t = self.expanded_non_space(files)?;
|
||||
self.begin_alignment_cell(end == Primitive::Span, files)?;
|
||||
self.begin_alignment_cell(end == Primitive::Span, end_span, files)?;
|
||||
self.begin_alignment_template(t)
|
||||
}
|
||||
fn extend_alignment_preamble(&mut self) -> Result<(), Error> {
|
||||
@@ -544,6 +566,8 @@ impl Executor {
|
||||
fn finish_alignment_row(&mut self) -> Result<(), Error> {
|
||||
let f = self.alignments.last_mut().unwrap();
|
||||
let cells = std::mem::take(&mut f.cells);
|
||||
f.row_span = None;
|
||||
f.cell_span = None;
|
||||
let mut node = if f.horizontal {
|
||||
let mut nodes = vec![TextNode::NamedGlue(f.skips[0], Parameter::Tabskip)];
|
||||
for cell in cells {
|
||||
|
||||
Reference in new issue
Block a user