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 {
|
||||
|
||||
@@ -20,17 +20,17 @@ pub(super) struct BoxFrame {
|
||||
pub(super) paragraph: Option<super::super::paragraph::Builder>,
|
||||
pub(super) vertical: VerticalBuilder,
|
||||
pub(super) span: Span,
|
||||
discretionary: Option<DiscretionaryFrame>,
|
||||
pub(super) discretionary: Option<DiscretionaryFrame>,
|
||||
pub(super) math: Vec<super::super::math::MathBuilder>,
|
||||
// An inner $...$ belongs to this box, even inside an outer display.
|
||||
display: Option<super::display::DisplayFrame>,
|
||||
pub(super) display: Option<super::display::DisplayFrame>,
|
||||
}
|
||||
#[derive(Clone)]
|
||||
struct DiscretionaryFrame {
|
||||
pub(super) struct DiscretionaryFrame {
|
||||
parts: Vec<Vec<TextNode>>,
|
||||
font: FontId,
|
||||
span: Span,
|
||||
math: Vec<super::super::math::MathBuilder>,
|
||||
pub(super) math: Vec<super::super::math::MathBuilder>,
|
||||
}
|
||||
impl BoxFrame {
|
||||
pub(super) fn collect_statistics(&self, c: &mut super::super::statistics::Collector) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::super::diagnostics::{DiagnosticNode, show_nodes, text_nodes, vertical_nodes};
|
||||
mod activity;
|
||||
use super::*;
|
||||
impl Executor {
|
||||
pub(super) fn trace_conditional(
|
||||
@@ -626,179 +626,6 @@ impl Executor {
|
||||
lines.push("### bottom level".into());
|
||||
lines
|
||||
}
|
||||
|
||||
fn activity_lists(
|
||||
&self,
|
||||
breadth: i32,
|
||||
depth: i32,
|
||||
wrap: bool,
|
||||
) -> Result<(String, BTreeSet<Dependency>), String> {
|
||||
if !self.math.is_empty()
|
||||
|| self.box_frames.iter().any(|frame| !frame.math.is_empty())
|
||||
|| !self.alignments.is_empty()
|
||||
|| self.output_frame.is_some()
|
||||
{
|
||||
return Err(
|
||||
"native showlists requires math, alignment or output nest diagnostics".into(),
|
||||
);
|
||||
}
|
||||
let mut frames = Vec::new();
|
||||
let mut enclosing_span = None;
|
||||
for frame in &self.box_frames {
|
||||
frames.push((frame.paragraph.as_ref(), &frame.vertical, enclosing_span));
|
||||
enclosing_span = Some(frame.span);
|
||||
}
|
||||
frames.push((self.paragraph.as_ref(), &self.vertical, enclosing_span));
|
||||
let mut text = String::new();
|
||||
let mut reads = BTreeSet::from([
|
||||
Dependency::ParagraphMode,
|
||||
Dependency::VerticalState,
|
||||
Dependency::PageState,
|
||||
Dependency::FontResources,
|
||||
Dependency::EscapeChar,
|
||||
Dependency::NewLineChar,
|
||||
]);
|
||||
let mut line = |span: Span| {
|
||||
reads.insert(Dependency::InputPosition(span.source));
|
||||
let prefix = self
|
||||
.sources
|
||||
.get(span.source)
|
||||
.and_then(|source| source.data.get(..span.start))
|
||||
.unwrap_or_default();
|
||||
let eols = prefix
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|&(index, byte)| {
|
||||
*byte == b'\r' || (*byte == b'\n' && (index == 0 || prefix[index - 1] != b'\r'))
|
||||
})
|
||||
.count();
|
||||
eols + 1
|
||||
};
|
||||
let mut levels = Vec::new();
|
||||
for (paragraph, vertical, span) in frames.into_iter().rev() {
|
||||
levels.push((
|
||||
paragraph.map(|p| (p, line(p.span))),
|
||||
vertical,
|
||||
span.map(&mut line),
|
||||
));
|
||||
}
|
||||
let mut render = |text: &mut String, nodes: &[DiagnosticNode]| -> Result<(), String> {
|
||||
let (part, used) =
|
||||
show_nodes(&self.state, nodes, breadth, depth, self.limits.tokens, wrap)?;
|
||||
if text.len().saturating_add(part.len()) > self.limits.tokens {
|
||||
return Err("native list diagnostic output limit exceeded".into());
|
||||
}
|
||||
text.push_str(&part);
|
||||
reads.extend(used);
|
||||
Ok(())
|
||||
};
|
||||
for (paragraph, vertical, enter) in levels {
|
||||
if !text.is_empty() {
|
||||
text.push('\n');
|
||||
}
|
||||
if let Some((paragraph, line)) = paragraph {
|
||||
let mode = if paragraph.restricted {
|
||||
"restricted horizontal"
|
||||
} else {
|
||||
"horizontal"
|
||||
};
|
||||
text.push_str(&format!("### {mode} mode entered at line {line}"));
|
||||
let language = paragraph.initial_language;
|
||||
if !paragraph.restricted
|
||||
&& (language.language != 0 || language.left_min != 2 || language.right_min != 3)
|
||||
{
|
||||
text.push_str(&format!(
|
||||
" (language{}:hyphenmin{},{})",
|
||||
language.language, language.left_min, language.right_min
|
||||
));
|
||||
}
|
||||
render(&mut text, &text_nodes(¶graph.nodes))?;
|
||||
text.push_str(&format!("\n\nspacefactor {}", paragraph.space_factor));
|
||||
if !paragraph.restricted && paragraph.current_language.language != 0 {
|
||||
text.push_str(&format!(
|
||||
", current language {}",
|
||||
paragraph.current_language.language
|
||||
));
|
||||
}
|
||||
if paragraph.restricted {
|
||||
continue;
|
||||
}
|
||||
text.push('\n');
|
||||
}
|
||||
let mode = if enter.is_some() {
|
||||
"internal vertical"
|
||||
} else {
|
||||
"vertical"
|
||||
};
|
||||
text.push_str(&format!(
|
||||
"### {mode} mode entered at line {}",
|
||||
enter.unwrap_or(0)
|
||||
));
|
||||
if enter.is_none()
|
||||
&& let Some(page) = &self.native_page
|
||||
{
|
||||
if !page.nodes.is_empty() {
|
||||
text.push_str("\n### current page:");
|
||||
render(&mut text, &vertical_nodes(&page.nodes))?;
|
||||
if page.started {
|
||||
let [goal, total, plus, fil, fill, filll, shrink, _] = page.dimensions;
|
||||
text.push_str(&format!(
|
||||
"\n\n total height {}",
|
||||
registers::print_scaled_wide(total)
|
||||
));
|
||||
for (value, unit) in
|
||||
[(plus, ""), (fil, "fil"), (fill, "fill"), (filll, "filll")]
|
||||
{
|
||||
if value != 0 {
|
||||
text.push_str(&format!(
|
||||
" plus {}{unit}",
|
||||
registers::print_scaled_wide(value)
|
||||
));
|
||||
}
|
||||
}
|
||||
if shrink != 0 {
|
||||
text.push_str(&format!(
|
||||
" minus {}",
|
||||
registers::print_scaled_wide(shrink)
|
||||
));
|
||||
}
|
||||
text.push_str(&format!(
|
||||
"\n goal height {}",
|
||||
registers::print_scaled_wide(goal)
|
||||
));
|
||||
}
|
||||
text.push('\n');
|
||||
}
|
||||
if !page.contributions.is_empty() {
|
||||
text.push_str("\n### recent contributions:");
|
||||
let pending: Vec<_> = page.contributions.iter().cloned().collect();
|
||||
render(&mut text, &vertical_nodes(&pending))?;
|
||||
}
|
||||
}
|
||||
if enter.is_none() && !vertical.nodes.is_empty() && self.native_page.is_some() {
|
||||
text.push_str("\n### recent contributions:");
|
||||
}
|
||||
render(&mut text, &vertical_nodes(&vertical.nodes))?;
|
||||
text.push_str("\n\nprevdepth ");
|
||||
if vertical.prev_depth <= -1000 * 65536 {
|
||||
text.push_str("ignored");
|
||||
} else {
|
||||
text.push_str(®isters::print_scaled(vertical.prev_depth));
|
||||
}
|
||||
if vertical.previous_lines != 0 {
|
||||
let suffix = if vertical.previous_lines == 1 {
|
||||
""
|
||||
} else {
|
||||
"s"
|
||||
};
|
||||
text.push_str(&format!(
|
||||
", prevgraf {} line{suffix}",
|
||||
vertical.previous_lines
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok((text, reads))
|
||||
}
|
||||
}
|
||||
|
||||
impl Executor {
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
use super::*;
|
||||
use crate::execution::{
|
||||
boxes::VerticalBuilder,
|
||||
diagnostics::{DiagnosticNode, show_math, show_nodes, text_nodes, vertical_nodes},
|
||||
math::MathBuilder,
|
||||
paragraph::Builder,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Default)]
|
||||
struct Entry {
|
||||
span: Option<Span>,
|
||||
output: bool,
|
||||
cell: bool,
|
||||
}
|
||||
|
||||
impl Entry {
|
||||
fn at(span: Span) -> Self {
|
||||
Self {
|
||||
span: Some(span),
|
||||
..Self::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SavedList<'a> {
|
||||
paragraph: Option<&'a Builder>,
|
||||
vertical: &'a VerticalBuilder,
|
||||
math: &'a [MathBuilder],
|
||||
display: bool,
|
||||
entry: Entry,
|
||||
}
|
||||
|
||||
enum Level<'a> {
|
||||
List(SavedList<'a>),
|
||||
AlignmentRow(&'a super::super::alignment::AlignmentFrame),
|
||||
}
|
||||
|
||||
enum Owner<'a> {
|
||||
Box(&'a super::super::boxes::BoxFrame),
|
||||
Alignment(&'a super::super::alignment::AlignmentFrame),
|
||||
Output(&'a super::super::page::OutputFrame),
|
||||
}
|
||||
|
||||
impl Executor {
|
||||
fn activity_line(&self, span: Span, reads: &mut BTreeSet<Dependency>) -> usize {
|
||||
reads.insert(Dependency::InputPosition(span.source));
|
||||
let prefix = self
|
||||
.sources
|
||||
.get(span.source)
|
||||
.and_then(|source| source.data.get(..span.start))
|
||||
.unwrap_or_default();
|
||||
prefix
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|&(index, byte)| {
|
||||
*byte == b'\r' || (*byte == b'\n' && (index == 0 || prefix[index - 1] != b'\r'))
|
||||
})
|
||||
.count()
|
||||
+ 1
|
||||
}
|
||||
|
||||
fn activity_levels(&self) -> Vec<Level<'_>> {
|
||||
// Box, alignment and output frames each retain their suspended lists.
|
||||
// The opening group depths give their order across those stacks.
|
||||
let mut owners = Vec::new();
|
||||
owners.extend(self.box_frames.iter().map(|f| (f.depth, Owner::Box(f))));
|
||||
owners.extend(
|
||||
self.alignments
|
||||
.iter()
|
||||
.map(|f| (f.depth, Owner::Alignment(f))),
|
||||
);
|
||||
owners.extend(
|
||||
self.output_frame
|
||||
.iter()
|
||||
.map(|f| (f.depth, Owner::Output(f))),
|
||||
);
|
||||
owners.sort_by_key(|(depth, _)| *depth);
|
||||
let mut levels = Vec::new();
|
||||
let mut entry = Entry::default();
|
||||
for (_, owner) in owners {
|
||||
match owner {
|
||||
Owner::Box(frame) => {
|
||||
let math = frame
|
||||
.discretionary
|
||||
.as_ref()
|
||||
.map_or(&frame.math[..], |disc| &disc.math[..]);
|
||||
levels.push(Level::List(SavedList {
|
||||
paragraph: frame.paragraph.as_ref(),
|
||||
vertical: &frame.vertical,
|
||||
math,
|
||||
display: frame.display.is_some(),
|
||||
entry,
|
||||
}));
|
||||
entry = Entry::at(frame.span);
|
||||
}
|
||||
Owner::Alignment(frame) => {
|
||||
levels.push(Level::List(SavedList {
|
||||
paragraph: frame.parent_paragraph.as_ref(),
|
||||
vertical: &frame.parent_vertical,
|
||||
math: &frame.parent_math,
|
||||
display: frame.parent_display.is_some(),
|
||||
entry,
|
||||
}));
|
||||
entry = Entry::at(frame.span);
|
||||
if let Some(cell) = frame.cell_span {
|
||||
levels.push(Level::List(SavedList {
|
||||
paragraph: frame.row_paragraph.as_ref(),
|
||||
vertical: &frame.row_vertical,
|
||||
math: &[],
|
||||
display: false,
|
||||
entry,
|
||||
}));
|
||||
levels.push(Level::AlignmentRow(frame));
|
||||
entry = Entry {
|
||||
cell: frame.horizontal,
|
||||
..Entry::at(cell)
|
||||
};
|
||||
}
|
||||
}
|
||||
Owner::Output(frame) => {
|
||||
levels.push(Level::List(SavedList {
|
||||
paragraph: frame.paragraph.as_ref(),
|
||||
vertical: &frame.vertical,
|
||||
math: &frame.math,
|
||||
display: frame.display.is_some(),
|
||||
entry,
|
||||
}));
|
||||
entry = Entry {
|
||||
output: true,
|
||||
..Entry::at(frame.span)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
levels.push(Level::List(SavedList {
|
||||
paragraph: self.paragraph.as_ref(),
|
||||
vertical: &self.vertical,
|
||||
math: &self.math,
|
||||
display: self.display.is_some(),
|
||||
entry,
|
||||
}));
|
||||
levels
|
||||
}
|
||||
|
||||
pub(super) fn activity_lists(
|
||||
&self,
|
||||
breadth: i32,
|
||||
depth: i32,
|
||||
wrap: bool,
|
||||
) -> Result<(String, BTreeSet<Dependency>), String> {
|
||||
let mut text = String::new();
|
||||
let auxiliary_break = if wrap { "\n" } else { "\n\n" };
|
||||
let mut reads = BTreeSet::from([
|
||||
Dependency::ParagraphMode,
|
||||
Dependency::VerticalState,
|
||||
Dependency::PageState,
|
||||
Dependency::FontResources,
|
||||
Dependency::EscapeChar,
|
||||
Dependency::NewLineChar,
|
||||
]);
|
||||
let render = |text: &mut String,
|
||||
reads: &mut BTreeSet<Dependency>,
|
||||
nodes: &[DiagnosticNode]|
|
||||
-> Result<(), String> {
|
||||
let remaining = self.limits.tokens.saturating_sub(text.len());
|
||||
let (part, used) = show_nodes(&self.state, nodes, breadth, depth, remaining, wrap)?;
|
||||
text.push_str(&part);
|
||||
reads.extend(used);
|
||||
Ok(())
|
||||
};
|
||||
for level in self.activity_levels().into_iter().rev() {
|
||||
if !text.is_empty() {
|
||||
text.push('\n');
|
||||
}
|
||||
let list = match level {
|
||||
Level::List(list) => list,
|
||||
Level::AlignmentRow(frame) => {
|
||||
let (span, nodes) = frame.activity_row().expect("active alignment row");
|
||||
let line = self.activity_line(span, &mut reads);
|
||||
let (mode, aux) = if frame.horizontal {
|
||||
("restricted horizontal", "spacefactor 0")
|
||||
} else {
|
||||
("internal vertical", "prevdepth 0.0")
|
||||
};
|
||||
text.push_str(&format!("### {mode} mode entered at line {line}"));
|
||||
render(&mut text, &mut reads, &nodes)?;
|
||||
text.push_str(&format!("{auxiliary_break}{aux}"));
|
||||
continue;
|
||||
}
|
||||
};
|
||||
for (index, math) in list.math.iter().enumerate().rev() {
|
||||
let mode = if list.display && index == 0 {
|
||||
"display math"
|
||||
} else {
|
||||
"math"
|
||||
};
|
||||
let line = self.activity_line(math.span, &mut reads);
|
||||
text.push_str(&format!("### {mode} mode entered at line {line}"));
|
||||
let remaining = self.limits.tokens.saturating_sub(text.len());
|
||||
let (part, used) = show_math(&self.state, math, breadth, depth, remaining, wrap)?;
|
||||
text.push_str(&part);
|
||||
if !wrap {
|
||||
text.push('\n');
|
||||
}
|
||||
reads.extend(used);
|
||||
}
|
||||
if let Some(paragraph) = list.paragraph {
|
||||
let mode = if paragraph.restricted {
|
||||
"restricted horizontal"
|
||||
} else {
|
||||
"horizontal"
|
||||
};
|
||||
let span = if list.entry.cell {
|
||||
list.entry.span.expect("alignment cell start")
|
||||
} else {
|
||||
paragraph.span
|
||||
};
|
||||
let line = self.activity_line(span, &mut reads);
|
||||
text.push_str(&format!("### {mode} mode entered at line {line}"));
|
||||
let language = paragraph.initial_language;
|
||||
if !paragraph.restricted
|
||||
&& (language.language != 0 || language.left_min != 2 || language.right_min != 3)
|
||||
{
|
||||
text.push_str(&format!(
|
||||
" (language{}:hyphenmin{},{})",
|
||||
language.language, language.left_min, language.right_min
|
||||
));
|
||||
}
|
||||
render(&mut text, &mut reads, &text_nodes(¶graph.nodes))?;
|
||||
text.push_str(&format!(
|
||||
"{auxiliary_break}spacefactor {}",
|
||||
paragraph.space_factor
|
||||
));
|
||||
if !paragraph.restricted && paragraph.current_language.language != 0 {
|
||||
text.push_str(&format!(
|
||||
", current language {}",
|
||||
paragraph.current_language.language
|
||||
));
|
||||
}
|
||||
if paragraph.restricted {
|
||||
continue;
|
||||
}
|
||||
text.push('\n');
|
||||
}
|
||||
let (mode, line) = match list.entry.span {
|
||||
Some(span) => ("internal vertical", self.activity_line(span, &mut reads)),
|
||||
None => ("vertical", 0),
|
||||
};
|
||||
text.push_str(&format!("### {mode} mode entered at line {line}"));
|
||||
if list.entry.output {
|
||||
text.push_str(r" (\output routine)");
|
||||
}
|
||||
if list.entry.span.is_none()
|
||||
&& let Some(page) = &self.native_page
|
||||
{
|
||||
let current_page = if page.output_active && !page.insertions.held.is_empty() {
|
||||
&page.insertions.held
|
||||
} else {
|
||||
&page.nodes
|
||||
};
|
||||
if !current_page.is_empty() {
|
||||
text.push_str("\n### current page:");
|
||||
if page.output_active {
|
||||
text.push_str(" (held over for next output)");
|
||||
}
|
||||
render(&mut text, &mut reads, &vertical_nodes(current_page))?;
|
||||
if page.activity_page_specs() {
|
||||
let [goal, total, plus, fil, fill, filll, shrink, _] = page.dimensions;
|
||||
text.push_str(&format!(
|
||||
"{auxiliary_break}total height {}",
|
||||
registers::print_scaled_wide(total)
|
||||
));
|
||||
for (value, unit) in
|
||||
[(plus, ""), (fil, "fil"), (fill, "fill"), (filll, "filll")]
|
||||
{
|
||||
if value != 0 {
|
||||
text.push_str(&format!(
|
||||
" plus {}{unit}",
|
||||
registers::print_scaled_wide(value)
|
||||
));
|
||||
}
|
||||
}
|
||||
if shrink != 0 {
|
||||
text.push_str(&format!(
|
||||
" minus {}",
|
||||
registers::print_scaled_wide(shrink)
|
||||
));
|
||||
}
|
||||
text.push_str(&format!(
|
||||
"\n goal height {}",
|
||||
registers::print_scaled_wide(goal)
|
||||
));
|
||||
let escape = u8::try_from(self.state.escapechar)
|
||||
.ok()
|
||||
.map_or_else(String::new, |c| char::from(c).to_string());
|
||||
for (class, size, split) in
|
||||
page.insertions.activity(&self.state, &page.nodes)
|
||||
{
|
||||
reads.insert(Dependency::Count(class.into()));
|
||||
text.push_str(&format!(
|
||||
"\n{escape}insert{class} adds {}",
|
||||
registers::print_scaled_wide(size)
|
||||
));
|
||||
if let Some(n) = split {
|
||||
text.push_str(&format!(", #{n} might split"));
|
||||
}
|
||||
}
|
||||
} else if !wrap {
|
||||
text.push('\n');
|
||||
}
|
||||
}
|
||||
if !page.contributions.is_empty() {
|
||||
text.push_str("\n### recent contributions:");
|
||||
let pending: Vec<_> = page.contributions.iter().cloned().collect();
|
||||
render(&mut text, &mut reads, &vertical_nodes(&pending))?;
|
||||
}
|
||||
}
|
||||
let vertical = list.vertical;
|
||||
if list.entry.span.is_none() && !vertical.nodes.is_empty() && self.native_page.is_some()
|
||||
{
|
||||
text.push_str("\n### recent contributions:");
|
||||
}
|
||||
render(&mut text, &mut reads, &vertical_nodes(&vertical.nodes))?;
|
||||
text.push_str(auxiliary_break);
|
||||
text.push_str("prevdepth ");
|
||||
if vertical.prev_depth <= -1000 * 65536 {
|
||||
text.push_str("ignored");
|
||||
} else {
|
||||
text.push_str(®isters::print_scaled(vertical.prev_depth));
|
||||
}
|
||||
if vertical.previous_lines != 0 {
|
||||
let suffix = if vertical.previous_lines == 1 {
|
||||
""
|
||||
} else {
|
||||
"s"
|
||||
};
|
||||
text.push_str(&format!(
|
||||
", prevgraf {} line{suffix}",
|
||||
vertical.previous_lines
|
||||
));
|
||||
}
|
||||
}
|
||||
if text.len() > self.limits.tokens {
|
||||
return Err("native list diagnostic output limit exceeded".into());
|
||||
}
|
||||
Ok((text, reads))
|
||||
}
|
||||
}
|
||||
@@ -786,7 +786,8 @@ impl Executor {
|
||||
| Knbccode | Knaccode | Letterspacefont | Textfont | Scriptfont
|
||||
| Scriptscriptfont | Endlinechar | Newlinechar | Escapechar | Globaldefs | Time
|
||||
| Day | Month | Year | BeginGroup | EndGroup | Relax | Message | Errmessage
|
||||
| Endinput | Showbox | Show | Showthe | Discretionary | DiscretionaryHyphen
|
||||
| Endinput | Showbox | Show | Showthe | Showlists | Showifs | Showgroups
|
||||
| Discretionary | DiscretionaryHyphen
|
||||
| Parshape | Partokenname => {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,12 @@ use super::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub(super) struct OutputFrame {
|
||||
depth: usize,
|
||||
paragraph: Option<super::super::paragraph::Builder>,
|
||||
vertical: VerticalBuilder,
|
||||
math: Vec<super::super::math::MathBuilder>,
|
||||
display: Option<super::display::DisplayFrame>,
|
||||
pub(super) depth: usize,
|
||||
pub(super) span: Span,
|
||||
pub(super) paragraph: Option<super::super::paragraph::Builder>,
|
||||
pub(super) vertical: VerticalBuilder,
|
||||
pub(super) math: Vec<super::super::math::MathBuilder>,
|
||||
pub(super) display: Option<super::display::DisplayFrame>,
|
||||
}
|
||||
impl OutputFrame {
|
||||
pub(super) fn collect_statistics(&self, c: &mut super::super::statistics::Collector) {
|
||||
@@ -151,6 +152,7 @@ impl Executor {
|
||||
}
|
||||
self.output_frame = Some(OutputFrame {
|
||||
depth: self.state.group_depth() + 1,
|
||||
span: self.current,
|
||||
paragraph: self.paragraph.take(),
|
||||
vertical: std::mem::take(&mut self.vertical),
|
||||
math: std::mem::take(&mut self.math),
|
||||
|
||||
Reference in new issue
Block a user