Skip to content

Commit

Permalink
Rearrange2 (brucemiller#2436)
Browse files Browse the repository at this point in the history
* New \lx@newpage (deprecate \LTX@newpage

* Moved \lx@ldots to more appropriate module

* Move \tiny,...\Huge to latex class files

* New utility \lx@end@document, for \end,\bye, and moved to TeX_Job

* Better handing of \tracingmacros,\tracingcommands

* \write to negative file handle should go only to log

* actually remove the removed definitions

* Add \tiny...\Huge to slides.cls as well, since no LoadClass there; Thanks d.ginev
  • Loading branch information
brucemiller authored Nov 15, 2024
1 parent 76e50b7 commit f2b2a7e
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 36 deletions.
3 changes: 3 additions & 0 deletions lib/LaTeXML/Engine/Base_Deprecated.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ DefMacro('\@@eqno',
DefMacro('\LTX@nonumber',
'\lx@DEPRECATE{\LTX@nonumber}{\lx@equation@nonumber}\lx@equation@nonumber');

DefMacro('\LTX@newpage',
'\lx@DEPRECATE{\LTX@newpage}{\lx@newpage}\lx@newpage');

DefMacro('\normal@par',
'\lx@DEPRECATE{\normnal@par}{\lx@normal@par}\lx@normal@par');
DefMacro('\inner@par',
Expand Down
12 changes: 12 additions & 0 deletions lib/LaTeXML/Engine/Base_XMath.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,18 @@ DefConstructor('\lx@text@tweaked RequiredKeyVals {}',
my ($kv, $body) = $whatsit->getArgs;
$whatsit->setProperties($kv->getPairs); });

#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DefConstructorI('\lx@ldots', undef,
"?#isMath(<ltx:XMTok name='ldots' font='#font' role='ID'>\x{2026}</ltx:XMTok>)(\x{2026})",
sizer => "\x{2026}",
reversion => '\ldots',
properties => sub {
(LookupValue('IN_MATH')
? (font => LookupValue('font')->merge(family => 'serif',
series => 'medium', shape => 'upright')->specialize("\x{2026}"))
: ()); }); # Since not DefMath!
# And so can \vdots

#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Support for rewrite rules
#**********************************************************************
Expand Down
4 changes: 2 additions & 2 deletions lib/LaTeXML/Engine/LaTeX.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -4755,8 +4755,8 @@ DefPrimitive('\nopagebreak[]', undef);
DefPrimitiveI('\columnbreak', undef, undef); # latex? or multicol?
DefPrimitive('\enlargethispage OptionalMatch:* {}', undef);

DefMacroI('\clearpage', undef, '\LTX@newpage');
DefMacroI('\cleardoublepage', undef, '\LTX@newpage');
DefMacroI('\clearpage', undef, '\lx@newpage');
DefMacroI('\cleardoublepage', undef, '\lx@newpage');
DefPrimitiveI('\samepage', undef, undef);

#**********************************************************************
Expand Down
18 changes: 12 additions & 6 deletions lib/LaTeXML/Engine/TeX_Debugging.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,20 @@ DefRegister('\showboxdepth' => Number(3));
# \tracingrestores pi if positive, writes save-stack details to the log file.
# \tracingstats pi if positive, writes memory usage statistics to the log file.

AssignValue(tracingmacros => Number(0));
AssignValue(tracingcommands => Number(0));
DefRegister('\tracingmacros', Number(0),
getter => sub { Number((LookupValue('TRACING') || 0) & TRACE_MACROS); },
setter => sub { my $p = (LookupValue('TRACING') || 0);
AssignValue(TRACING => ($_[0]->valueOf ? $p | TRACE_MACROS : $p & ~TRACE_MACROS)); });
getter => sub { LookupValue('tracingmacros'); },
setter => sub {
AssignValue(tracingmacros => $_[0]);
my $p = (LookupValue('TRACING') || 0);
AssignValue(TRACING => ($_[0]->valueOf > 0 ? $p | TRACE_MACROS : $p & ~TRACE_MACROS)); });
DefRegister('\tracingcommands', Number(0),
getter => sub { Number((LookupValue('TRACING') || 0) & TRACE_COMMANDS); },
setter => sub { my $p = (LookupValue('TRACING') || 0);
AssignValue(TRACING => ($_[0]->valueOf ? $p | TRACE_COMMANDS : $p & ~TRACE_COMMANDS)); });
getter => sub { LookupValue('tracingcommands'); },
setter => sub {
AssignValue(tracingcommands => $_[0]);
my $p = (LookupValue('TRACING') || 0);
AssignValue(TRACING => ($_[0]->valueOf > 0 ? $p | TRACE_COMMANDS : $p & ~TRACE_COMMANDS)); });

DefRegister('\tracingonline' => Number(0));
DefRegister('\tracingstats' => Number(0));
Expand Down
2 changes: 2 additions & 0 deletions lib/LaTeXML/Engine/TeX_FileIO.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ DefPrimitive('\write Number XGeneralText', sub {
my $handle = $filename . '_contents';
my $contents = LookupValue($handle);
AssignValue($handle => $contents . UnTeX($tokens, 1) . "\n", 'global'); }
elsif ($port < 0) {
NoteLog(UnTeX($tokens)); }
else {
Note(UnTeX($tokens)); }
return; });
Expand Down
4 changes: 3 additions & 1 deletion lib/LaTeXML/Engine/TeX_Job.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ sub today {
# \deadcycles iq is the number of times \output was called since the last \shipout.
# \maxdeadcycles pi is the maximum allowed value of \deadcycles before an error is generated.

DefPrimitiveI('\end', undef, sub { $_[0]->getGullet->flush; return; });
DefPrimitiveI('\lx@end@document', undef, sub { $_[0]->getGullet->flush; return; });
Let('\end', '\lx@end@document');

DefRegister('\everyjob' => Tokens());
DefRegister('\deadcycles' => Number(0));
DefRegister('\maxdeadcycles' => Number(0));
Expand Down
4 changes: 4 additions & 0 deletions lib/LaTeXML/Engine/TeX_Page.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,9 @@ DefRegister('\pagefilstretch' => Dimension(0));
DefRegister('\pagefillstretch' => Dimension(0));
DefRegister('\pagefilllstretch' => Dimension(0));

#======================================================================
# Usable for things line \clearpage, etc.
DefConstructorI('\lx@newpage', undef, "^<ltx:pagination role='newpage'/>");

#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1;
31 changes: 4 additions & 27 deletions lib/LaTeXML/Engine/plain.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use charnames ':full';

DefRegister('\magnification' => Number(1000));

Let('\bye', '\end');
Let('\bye', '\lx@end@document');

# Most of these are ignored, but...
DefMacro('\tracingall',
Expand Down Expand Up @@ -417,16 +417,6 @@ DefPrimitiveI('\cal', undef, sub {

# Ideally, we should set these sizes from class files
AssignValue(NOMINAL_FONT_SIZE => 10);
DefPrimitiveI('\tiny', undef, undef, font => { size => 5 });
DefPrimitiveI('\scriptsize', undef, undef, font => { size => 7 });
DefPrimitiveI('\footnotesize', undef, undef, font => { size => 8 });
DefPrimitiveI('\small', undef, undef, font => { size => 9 });
DefPrimitiveI('\normalsize', undef, undef, font => { size => 10 });
DefPrimitiveI('\large', undef, undef, font => { size => 12 });
DefPrimitiveI('\Large', undef, undef, font => { size => 14.4 });
DefPrimitiveI('\LARGE', undef, undef, font => { size => 17.28 });
DefPrimitiveI('\huge', undef, undef, font => { size => 20.74 });
DefPrimitiveI('\Huge', undef, undef, font => { size => 29.8 });

DefPrimitiveI('\mit', undef, undef, requireMath => 1, font => { family => 'italic' });

Expand Down Expand Up @@ -541,11 +531,9 @@ DefMacro("~", '\nobreakspace{}');
DefMacroI('\slash', undef, '/');
DefPrimitiveI('\filbreak', undef, undef);
DefMacroI('\goodbreak', undef, '\par');
DefMacroI('\eject', undef, '\par\LTX@newpage');
DefMacroI('\eject', undef, '\par\lx@newpage');
Let('\newpage', '\eject');
DefConstructorI('\LTX@newpage', undef, "^<ltx:pagination role='newpage'/>");

DefMacroI('\supereject', undef, '\par\LTX@newpage');
DefMacroI('\supereject', undef, '\par\lx@newpage');
DefPrimitiveI('\removelastskip', undef, undef);
DefMacroI('\smallbreak', undef, '\par');
DefMacroI('\medbreak', undef, '\par');
Expand Down Expand Up @@ -767,8 +755,6 @@ foreach my $op ('\hrulefill', '\dotfill', '\rightarrowfill', '\leftarrowfill',
'\upbracefill', '\downbracefill') {
DefPrimitiveI($op, undef, undef); }

#Let('\bye', '\end');

Let('\sp', T_SUPER);
Let('\sb', T_SUB);

Expand Down Expand Up @@ -1197,16 +1183,7 @@ DefMathI('\rhook', undef, "\x{2E27}"); # TeX 312D

# Ah, since \ldots can appear in text and math....
DefMacroI('\ldots', undef, '\lx@ldots');
DefConstructorI('\lx@ldots', undef,
"?#isMath(<ltx:XMTok name='ldots' font='#font' role='ID'>\x{2026}</ltx:XMTok>)(\x{2026})",
sizer => "\x{2026}",
reversion => '\ldots',
properties => sub {
(LookupValue('IN_MATH')
? (font => LookupValue('font')->merge(family => 'serif',
series => 'medium', shape => 'upright')->specialize("\x{2026}"))
: ()); }); # Since not DefMath!
# And so can \vdots

DefConstructorI('\vdots', undef,
"?#isMath(<ltx:XMTok name='vdots' font='#font' role='ID'>\x{22EE}</ltx:XMTok>)(\x{22EE})",
sizer => "\x{22EE}",
Expand Down
12 changes: 12 additions & 0 deletions lib/LaTeXML/Package/article.cls.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,17 @@ DefMacro('\appendix', '\@appendix');
# Actually we should be using section counter
DefPrimitive('\@appendix', sub { startAppendices('section'); });

#======================================================================
DefPrimitiveI('\tiny', undef, undef, font => { size => 5 });
DefPrimitiveI('\scriptsize', undef, undef, font => { size => 7 });
DefPrimitiveI('\footnotesize', undef, undef, font => { size => 8 });
DefPrimitiveI('\small', undef, undef, font => { size => 9 });
DefPrimitiveI('\normalsize', undef, undef, font => { size => 10 });
DefPrimitiveI('\large', undef, undef, font => { size => 12 });
DefPrimitiveI('\Large', undef, undef, font => { size => 14.4 });
DefPrimitiveI('\LARGE', undef, undef, font => { size => 17.28 });
DefPrimitiveI('\huge', undef, undef, font => { size => 20.74 });
DefPrimitiveI('\Huge', undef, undef, font => { size => 29.8 });

#**********************************************************************
1;
11 changes: 11 additions & 0 deletions lib/LaTeXML/Package/book.cls.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,16 @@ DefPrimitive('\backmatter', undef);
# commands for bibliography, indices
# \end{document}

#======================================================================
DefPrimitiveI('\tiny', undef, undef, font => { size => 5 });
DefPrimitiveI('\scriptsize', undef, undef, font => { size => 7 });
DefPrimitiveI('\footnotesize', undef, undef, font => { size => 8 });
DefPrimitiveI('\small', undef, undef, font => { size => 9 });
DefPrimitiveI('\normalsize', undef, undef, font => { size => 10 });
DefPrimitiveI('\large', undef, undef, font => { size => 12 });
DefPrimitiveI('\Large', undef, undef, font => { size => 14.4 });
DefPrimitiveI('\LARGE', undef, undef, font => { size => 17.28 });
DefPrimitiveI('\huge', undef, undef, font => { size => 20.74 });
DefPrimitiveI('\Huge', undef, undef, font => { size => 29.8 });
#**********************************************************************
1;
11 changes: 11 additions & 0 deletions lib/LaTeXML/Package/report.cls.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,16 @@ Tag('ltx:appendix', autoClose => 1);
DefMacro('\appendix', '\@appendix');
DefPrimitive('\@appendix', sub { startAppendices('chapter'); });

#======================================================================
DefPrimitiveI('\tiny', undef, undef, font => { size => 5 });
DefPrimitiveI('\scriptsize', undef, undef, font => { size => 7 });
DefPrimitiveI('\footnotesize', undef, undef, font => { size => 8 });
DefPrimitiveI('\small', undef, undef, font => { size => 9 });
DefPrimitiveI('\normalsize', undef, undef, font => { size => 10 });
DefPrimitiveI('\large', undef, undef, font => { size => 12 });
DefPrimitiveI('\Large', undef, undef, font => { size => 14.4 });
DefPrimitiveI('\LARGE', undef, undef, font => { size => 17.28 });
DefPrimitiveI('\huge', undef, undef, font => { size => 20.74 });
DefPrimitiveI('\Huge', undef, undef, font => { size => 29.8 });
#**********************************************************************
1;
11 changes: 11 additions & 0 deletions lib/LaTeXML/Package/slides.cls.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,16 @@ DefEnvironment('{note}',
properties => sub { (doslide => sub { LookupValue('DONOTES'); },
RefStepCounter('note')) });

#======================================================================
DefPrimitiveI('\tiny', undef, undef, font => { size => 5 });
DefPrimitiveI('\scriptsize', undef, undef, font => { size => 7 });
DefPrimitiveI('\footnotesize', undef, undef, font => { size => 8 });
DefPrimitiveI('\small', undef, undef, font => { size => 9 });
DefPrimitiveI('\normalsize', undef, undef, font => { size => 10 });
DefPrimitiveI('\large', undef, undef, font => { size => 12 });
DefPrimitiveI('\Large', undef, undef, font => { size => 14.4 });
DefPrimitiveI('\LARGE', undef, undef, font => { size => 17.28 });
DefPrimitiveI('\huge', undef, undef, font => { size => 20.74 });
DefPrimitiveI('\Huge', undef, undef, font => { size => 29.8 });
#**********************************************************************
1;

0 comments on commit f2b2a7e

Please sign in to comment.