Skip to content
Permalink
Browse files

fork on \include, not on \input

fixes \scalebox{2}{\input{test2}}

\include is guaranteed to be at top level

forking to save memory is probably not important these days
  • Loading branch information
Dan Gildea
Dan Gildea committed Sep 22, 2019
1 parent f4063c6 commit c2f59b1453e511dc94ebf0093c2fb483c6cfeef7
Showing with 20 additions and 15 deletions.
  1. +1 −0 Changes
  2. +12 −9 latex2html.pin
  3. +7 −6 texexpand.pin
@@ -113,6 +113,7 @@
# the top.
#
#
# - fork on \include, not on \input
# - fix figure size with png
# - allow verbatim in figure
# - output height with displaymath, center displaymath
@@ -1755,7 +1755,7 @@ sub wrap_other_environments {
# Reads the entire input file and performs pre_processing operations
# on it before returning it as a single string. The pre_processing is
# done on separate chunks of the input file by separate Unix processes
# as determined by LaTeX \input commands, in order to reduce the memory
# as determined by LaTeX \include commands, in order to reduce the memory
# requirements of LaTeX2HTML.
sub slurp_input_and_partition_and_pre_process {
local($file) = @_;
@@ -1768,7 +1768,7 @@ sub slurp_input_and_partition_and_pre_process {
local(@file_string);
print STDOUT "$file" if ($VERBOSITY >1);
while (<SINPUT>) {
if (/TEXEXPAND: INCLUDED FILE MARKER (\S*)/) {
if (/TEXEXPAND: \\include FILE MARKER (\S*)/) {
# Forking seems to screw up the rest of the input stream
# We save the current position ...
$pos = tell SINPUT;
@@ -2199,7 +2199,7 @@ sub do_cmd_htmllanguagestyle {
# a) preample
# b) \begin{document}
# c) text
# d) \input{chapter}
# d) \include{chapter}
# e) more text
# f) \end{document}
#
@@ -7127,12 +7127,13 @@ sub make_latex{
\newbox\lthtmlPageBox
\newdimen\lthtmlCropMarkHeight
\newdimen\lthtmlCropMarkDepth
\long\def\lthtmlTightVBox#1#2{%
\setbox\lthtmlPageBox\vbox{\hbox{\catcode`\_=8 #2}}%
\long\def\lthtmlTightVBoxA#1{\def\lthtmllabel{#1}
\setbox\lthtmlPageBox\vbox\bgroup\hbox\bgroup\catcode`\_=8 }%
\long\def\lthtmlTightVBoxZ{\egroup\egroup
\lthtmlCropMarkHeight=\ht\lthtmlPageBox \advance \lthtmlCropMarkHeight 6pt
\lthtmlCropMarkDepth=\dp\lthtmlPageBox
\lthtmltypeout{^^J:#1:lthtmlCropMarkHeight:=\the\lthtmlCropMarkHeight}%
\lthtmltypeout{^^J:#1:lthtmlCropMarkDepth:=\the\lthtmlCropMarkDepth:1ex:=\the \dimexpr 1ex}%
\lthtmltypeout{^^J:\lthtmllabel:lthtmlCropMarkHeight:=\the\lthtmlCropMarkHeight}%
\lthtmltypeout{^^J:\lthtmllabel:lthtmlCropMarkDepth:=\the\lthtmlCropMarkDepth:1ex:=\the \dimexpr 1ex}%
\begin{preview}\copy\lthtmlPageBox\end{preview}}%
\long\def\lthtmlTightFBoxA#1{\def\lthtmllabel{#1}%
\adjustnormalsize\setbox\lthtmlPageBox=\vbox\bgroup %
@@ -7158,8 +7159,10 @@ sub make_latex{
\lthtmlTightFBoxA{#1}}
\long\def\lthtmlfigureZ{
\lthtmlTightFBoxZ\global\let\@freelist\@savefreelist}
\long\def\lthtmlpictureA#1#2\lthtmlpictureZ{\let\@savefreelist\@freelist
\lthtmlTightVBox{#1}{#2}\global\let\@freelist\@savefreelist}
\long\def\lthtmlpictureA#1{\let\@savefreelist\@freelist
\lthtmlTightVBoxA{#1}}
\long\def\lthtmlpictureZ{
\lthtmlTightVBoxZ\global\let\@freelist\@savefreelist}
</dvipng>
"\\newcommand\\lthtmlhboxmathA{\\adjustnormalsize\\setbox\\sizebox=\\hbox\\bgroup\\kern.05em }%\n" .
"\\newcommand\\lthtmlhboxmathB{\\adjustnormalsize\\setbox\\sizebox=\\hbox to\\hsize\\bgroup\\hfill }%\n" .
@@ -669,7 +669,8 @@ sub main {
# ``Document Segmentation'' of the LaTeX2HTML manual.
#
sub process_file {
my ($infile) = @_;
my ($infile, $cmd) = @_;
# $infile is filename, $cmd is \input, \include or undef
local(*IN);
local($comments,$before,$orig);

@@ -682,7 +683,7 @@ sub process_file {

# if we don't include this file marker LaTeX2HTML won't split
# the document at this point
print OUT "%%% TEXEXPAND: INCLUDED FILE MARKER $infile\n"
print OUT "%%% TEXEXPAND: $cmd FILE MARKER $infile\n"
if ($includelevel > 1 && $active);

if ($segmentfile) {
@@ -1027,7 +1028,7 @@ sub interprete {

sub process_input_include_file {
local($_) = @_;
local($before,$after,$class,$styles);
local($before,$after,$class,$styles,$cmd);
$_ =~ s/\n$//;

print STDERR "$prompt %--- Found include at level $includelevel: $_"
@@ -1038,11 +1039,11 @@ sub process_input_include_file {

# $class serves as temporary storage
if (/(\\input|\\include)\s*$arg_rx/o) {
($before,$after,$class,$filename) = ($`, $', $&, $2);
($before,$after,$class,$filename,$cmd) = ($`, $', $&, $2, $1);
$filename =~ s/\s//g;
}
elsif (/(\\input|\\include)\s+(\S+)(?=\s|$)/o) {
($before,$after,$class,$filename) = ($`, $', $&, $2);
($before,$after,$class,$filename,$cmd) = ($`, $', $&, $2, $1);
$filename =~ s/\s//g;
}
else {
@@ -1074,7 +1075,7 @@ sub process_input_include_file {
print OUT "$before";

# recursive call
&process_file($fname);
&process_file($fname,$cmd);

print OUT $after if($after =~ /\S+/);
print STDERR "$prompt %--- successfully included $filename"

0 comments on commit c2f59b1

Please sign in to comment.
You can’t perform that action at this time.