Support common class declarations and page length registers

This commit is contained in:
gloamxun committed 2026-10-19 23:15:22 +08:00
1 parent 34c8b7d6ec
commit 3eb4e81956
2 files changed
+88 -3

No files matched your search

+76 -3
View File
@@ -410,6 +410,21 @@ const PRELUDE: &str = r#"
\def\textless{<}
\def\textgreater{>}
\def\textbar{|}
\def\_{ extunderscore}
\def\DeclareOldFontCommand#1#2#3{\def#1{#2}}
\def\@fontswitch#1#2{#2}
\def\DeclareMathSizes#1#2#3#4{}\def\hyphenation#1{}
\def\newbox#1{\def#1{}}
\def\newsavebox#1{\def#1{}}
\def\sbox#1#2{\def#1{#2}}
\def\savebox#1#2{\def#1{#2}}
\def\usebox#1{#1}
\def\DeclareSymbolFont#1#2#3#4#5{}
\def\DeclareMathSymbol#1#2#3#4{}
\def\DeclareNewFootnote#1{}
\def\SetFootnoteHook#1{}
\def\textunderscore{_}
\def\guillemotleft{«}
\def\guillemotright{»}
@@ -469,6 +484,18 @@ const PRELUDE: &str = r#"
\def\figurename{Figure}
\def\tablename{Table}
\def\contentsname{Contents}
\def\appendixname{Appendix}
\def\listfigurename{List of Figures}
\def\listtablename{List of Tables}
\def\refname{References}
\def\bibname{Bibliography}
\def\indexname{Index}
\def\figurename{Figure}
\def\tablename{Table}
\def\partname{Part}
\def\chaptername{Chapter}
\def\proofname{Proof}
\def\keywords#1{\par\noindent\textbf{Keywords: }#1\par}
\def\hbox#1{#1}
\def\rule{\texrrarule}
@@ -499,11 +526,53 @@ const PRELUDE: &str = r#"
\skipdef\labelwidth=119
\skipdef\itemindent=120
\skipdef\listparindent=121
\skipdef\headheight=128
\headheight=12pt\relax
\skipdef\headsep=129
\headsep=25pt\relax
\skipdef\footskip=130
\footskip=30pt\relax
\skipdef\textfloatsep=131
\skipdef\floatsep=132
\skipdef\intextsep=133
\skipdef\dbltextfloatsep=134
\skipdef\dblfloatsep=135
\skipdef\columnsep=136
\skipdef\arraycolsep=137
\skipdef\maxdepth=138
\skipdef\normallineskip=139
\normallineskip=1pt\relax
\skipdef\overfullrule=140
\skipdef\tabbingsep=141
\skipdef\columnhsize=142
\skipdef\tabcolsep=143
\tabcolsep=6pt\relax
\skipdef\arrayrulewidth=144
\arrayrulewidth=0.4pt\relax
\skipdef\doublerulesep=145
\doublerulesep=2pt\relax
\countdef\@lowpenalty=210
\@lowpenalty=51
\countdef\@medpenalty=211
\@medpenalty=151
\countdef\@highpenalty=212
\@highpenalty=301
\countdef\widowpenalty=200
\countdef\clubpenalty=201
\countdef\displaywidowpenalty=202
\countdef\brokenpenalty=203
\countdef\footins=204
\countdef\predisplaypenalty=213
\countdef\postdisplaypenalty=214
\countdef\doublehyphendemerits=215
\countdef\finalhyphendemerits=216
\countdef\interlinepenalty=217\countdef\lefthyphenmin=218
\countdef\righthyphenmin=219
\countdef\hyphenpenalty=220
\countdef\exhyphenpenalty=221
\countdef\pretolerance=205
\countdef\tolerance=206
\countdef\hbadness=207
@@ -514,10 +583,14 @@ const PRELUDE: &str = r#"
\def\textfraction{0.2}
\def\floatpagefraction{0.5}
\def\dbltopfraction{0.7}
\def\dblfloatpagefraction{0.5}
\def\floatpagefraction{0.5}
\def\dblbottomfraction{0.3}
\def\arraystretch{1}
\def\tabcolsep{6pt}
\def\arrayrulewidth{0.4pt}
\def\doublerulesep{2pt}
\def\extrarowheight{0pt}
"#;
+12
View File
@@ -2770,6 +2770,13 @@ fn newcommand_primitive(
define_latex_command(token, input, LatexCommandDefinition::New)
}
fn declare_robust_command_primitive(
token: token::Token,
input: &mut vm::ExecutionInput<CompilerState>,
) -> texlang::prelude::Result<()> {
define_latex_command(token, input, LatexCommandDefinition::Provide)
}
fn font_primitive(
token: token::Token,
input: &mut vm::ExecutionInput<CompilerState>,
@@ -6998,6 +7005,11 @@ fn built_in_commands() -> HashMap<&'static str, texlang::command::BuiltIn<Compil
texlang::command::BuiltIn::new_execution(newcommand_primitive)
.with_tag(texlang_stdlib::def::def_tag()),
);
built_ins.insert(
"DeclareRobustCommand",
texlang::command::BuiltIn::new_execution(declare_robust_command_primitive)
.with_tag(texlang_stdlib::def::def_tag()),
);
built_ins.insert(
"renewcommand",
texlang::command::BuiltIn::new_execution(renewcommand_primitive)