Capture vertical material in vbox and vtop

This commit is contained in:
gloamxun committed 2026-10-19 14:34:22 +08:00
1 parent 5e9552d785
commit 7ad3c327ec
8 files changed
+99 -14

No files matched your search

-2
View File
@@ -28,8 +28,6 @@ const PRELUDE: &str = r#"
\def\today{__TEXRRA_TODAY__}
\def\maketitle{\texrramaketitle}
\def\noindent{\texrranoindent}
\def\vbox#1{\parbox{\textwidth}{#1}}
\def\vtop#1{\parbox{\textwidth}{#1}}
\def\hfill{\hskip0pt plus 1fil\relax}
\def\hfil{\hskip0pt plus 1fil\relax}
\def\allowbreak{\penalty0}
+37
View File
@@ -3442,6 +3442,31 @@ fn parbox_primitive(
Ok(())
}
fn vbox_primitive(
token: token::Token,
input: &mut vm::ExecutionInput<CompilerState>,
) -> texlang::prelude::Result<()> {
let content = read_unexpanded_argument(input, token, "expects box content")?;
let inner = strip_braced_tokens(&content).to_vec();
write_event(input, token, FrontendEventKind::VBoxStart);
let trace_key = token.trace_key();
let mut expansion = inner;
expansion.push(control_sequence_token(input, "texrravboxend", trace_key));
input
.as_mut()
.expansions_mut()
.extend(expansion.into_iter().rev());
Ok(())
}
fn vbox_end_primitive(
token: token::Token,
input: &mut vm::ExecutionInput<CompilerState>,
) -> texlang::prelude::Result<()> {
write_event(input, token, FrontendEventKind::VBoxEnd);
Ok(())
}
fn fbox_primitive(
token: token::Token,
input: &mut vm::ExecutionInput<CompilerState>,
@@ -6728,6 +6753,18 @@ fn built_in_commands() -> HashMap<&'static str, texlang::command::BuiltIn<Compil
"texrraframedboxend",
texlang::command::BuiltIn::new_execution(framed_box_end_primitive),
);
built_ins.insert(
"vbox",
texlang::command::BuiltIn::new_execution(vbox_primitive),
);
built_ins.insert(
"vtop",
texlang::command::BuiltIn::new_execution(vbox_primitive),
);
built_ins.insert(
"texrravboxend",
texlang::command::BuiltIn::new_execution(vbox_end_primitive),
);
built_ins.insert(
"texrrarule",
texlang::command::BuiltIn::new_execution(rule_primitive),