Debian Codegraph @

texmf-dist/doc/latex/foilhtml/foils.perl

raw
1 ######################################################
2 #
3 # This is file `foils.perl',
4 # generated with the docstrip utility.
5 #
6 # Copyright Boris Veytsman 1998
7 #
8 # You are *not* allowed to modify this file.
9 #
10 # You are *not* allowed to distribute this file.
11 # For distribution of the original source see
12 # the terms for copying and modification in the file
13 # foilhtml.dtx
14 #
15 $FOILHEADLEVEL = 4 unless defined($FOILHEADLEVEL);
16 %section_commands=('foilhead',$FOILHEADLEVEL,
17 'rotatefoilhead',$FOILHEADLEVEL,%section_commands);
18
19 %new_section_headings = ('foilhead', 'H1','rotatefoilhead','H1');
20 &generate_new_sectioning_subs;
21
22 sub generate_new_sectioning_subs{
23 local($key, $val);
24 while ( ($key, $val) = each %new_section_headings) {
25 eval "sub do_cmd_$key {"
26 . 'local($after) = @_;'
27 . '&do_cmd_section_helper(' . $val . ');}';
28 %section_commands=($key,$val,%section_commands);
29 }
30 };
31 $FOILCLASS = 'article' unless defined $FOILCLASS;
32 $FOILOPTIONS = '10pt' unless defined $FOILOPTIONS;
33 sub make_latex{
34 # This is the environment in which to process constructs that cannot be
35 # translated to HTML.
36 # The environment tex2html_wrap will be wrapped around any shorthand
37 # environments (e.g. $, \(, \[).
38 # The tex2html_wrap environment will be treated as an unrecognised
39 # evironment by the translator and its contents (i.e. the 'shorthand'
40 # environment) will be passed to latex for processing as usual.
41 local($contents) = @_;
42 local($preamble) = $preamble;
43 local($aux_preamble) = $aux_preamble;
44 while ($preamble =~ s/^(\@.*\n)/$prelatex .= $1;''/e) {}
45 print "\nPRE-LATEX: $prelatex" if (($prelatex)&&($VERBOSITY > 1));
46
47 # Make the @ character a normal letter ...
48 $preamble =~ s/\\par([^A-Za-z])/\n$1/g;
49 $preamble =~
50 s/\\documentclass.*/
51 \\documentclass\[$FOILOPTIONS\]{$FOILCLASS}\\makeatletter/;
52 # ... and make it special again after the preamble
53 # remove the \begin/\end for tex2html_nowrap and tex2html_deferred environments
54 $preamble =~s/\\(begin|end)\s*\{(tex2html_(nowrap|deferred|nomath|preform)[_a-z]*|imagesonly)\}//g;
55 $preamble = "\\documentclass\{article\}%\n\\usepackage{html,color}%\n\\makeatletter"
56 unless ($preamble);
57 if (($LATEX_DUMP)&&(!($preamble =~ /\\usepackage\{ldump\}/))) {
58 $*=1;
59 $preamble =~ s/(\\document(class|style)[^\n]*\n)/$1\\usepackage\{ldump\}\n/;
60 $*=0;
61 }
62 $LOAD_LATEX_COLOR = "\\usepackage[dvips]{color}" unless $LOAD_LATEX_COLOR;
63 $LATEX_COLOR = "\\pagecolor[gray]{.85}" unless $LATEX_COLOR;
64 if ($preamble =~ /(^|\s*[^%])\s*\\documentstyle/) {
65 # \usepackage is invalid in LaTeX 2.09 and LaTeX-2e compatibility mode
66 $LATEX_COLOR = ''; $LOAD_LATEX_COLOR = '';
67 }
68
69 $preamble .= $LOAD_LATEX_COLOR."\n" unless ($preamble =~ /[,\{]color[,\}]/);
70 $preamble .= $LATEX_COLOR."\n" unless ($preamble =~ /\\pagecolor/);
71
72 $aux_preamble = '' unless (($aux_preamble)&&($contents =~ /\\(hyper)?(ref|cite)/));
73
74 local($paperwidth) = '';
75 if ($PAPERSIZE) { $paperwidth = &adjust_textwidth($PAPERSIZE); }
76 else { $paperwidth = &adjust_textwidth("a5"); }
77 local($kern) = ($EXTRA_IMAGE_SCALE ? $EXTRA_IMAGE_SCALE/2 : ".5" );
78 $kern = $kern * $MATH_SCALE_FACTOR;
79 $prelatex . ($DEBUG ? "\\nonstopmode" : "\\batchmode") .
80 "\n$preamble\n$aux_preamble\n" .
81 "\\count\@=\\the\\catcode`\\_ \\catcode`\\_=8 \n" .
82 "\\newenvironment{tex2html_wrap}{}{} \\catcode`\\_=\\count\@\n" .
83 "\\makeatother\n" .
84 "\\ifx\\AtBeginDocument\\undefined \\newcommand{\\AtBeginDocument}[1]{}\\fi\n" .
85 "\\newbox\\sizebox\n" . "$paperwidth" .
86 "\\newwrite\\lthtmlwrite\n" . "\\makeatletter\n" .
87 "\\let\\realnormalsize=\\normalsize\n\\global\\topskip=2sp\n\\def\\preveqno{}" .
88 "\\let\\real\@float=\\\@float \\let\\realend\@float=\\end\@float\n" .
89 "\\def\\\@float{\\let\\\@savefreelist\\\@freelist\\real\@float}\n" .
90 # "\\def\\\@float{\\\@dbflt}\n" .
91 "\\def\\end\@float{\\realend\@float\\global\\let\\\@freelist\\\@savefreelist}\n" .
92 "\\let\\real\@dbflt=\\\@dbflt \\let\\end\@dblfloat=\\end\@float\n" .
93 "\\let\\\@largefloatcheck=\\relax\n" .
94 "\\def\\\@dbflt{\\let\\\@savefreelist\\\@freelist\\real\@dbflt}\n" .
95 "\\def\\adjustnormalsize{\\def\\normalsize{\\mathsurround=0pt \\realnormalsize\n" .
96 " \\parindent=0pt\\abovedisplayskip=0pt\\belowdisplayskip=0pt}\\normalsize}%\n" .
97 "\\def\\lthtmltypeout#1{{\\let\\protect\\string\\immediate\\write\\lthtmlwrite{#1}}}%\n" .
98 "\\newcommand\\lthtmlhboxmathA{\\adjustnormalsize\\setbox\\sizebox=\\hbox\\bgroup}%\n" .
99 "\\newcommand\\lthtmlvboxmathA{\\adjustnormalsize\\setbox\\sizebox=\\vbox\\bgroup%\n".
100 " \\let\\ifinner=\\iffalse }%\n" .
101 "\\newcommand\\lthtmlboxmathZ{\\\@next\\next\\\@currlist{}{\\def\\next{\\voidb\@x}}%\n" .
102 # " \\expandafter\\box\\next\\edef\\next{\\egroup\\def\\noexpand\\thiseqn{\\theequation}}\\next}%\n" .
103 " \\expandafter\\box\\next\\egroup}%\n" .
104 "\\newcommand\\lthtmlmathtype[1]{\\def\\lthtmlmathenv{#1}}%\n" .
105 "\\newcommand\\lthtmllogmath{\\lthtmltypeout{l2hSize %\n" .
106 ":\\lthtmlmathenv:\\the\\ht\\sizebox::\\the\\dp\\sizebox::\\the\\wd\\sizebox.\\preveqno}}%\n" .
107 "\\newcommand\\lthtmlfigureA[1]{\\let\\\@savefreelist\\\@freelist
108 \\lthtmlmathtype{#1}\\lthtmlvboxmathA}%\n" .
109 "\\newcommand\\lthtmlfigureZ{\\lthtmlboxmathZ\\lthtmllogmath\\copy\\sizebox
110 \\global\\let\\\@freelist\\\@savefreelist}%\n" .
111 "\\newcommand\\lthtmldisplayA[1]{\\lthtmlmathtype{#1}\\lthtmlvboxmathA}%\n" .
112 "\\newcommand\\lthtmldisplayB[1]{\\edef\\preveqno{(\\theequation)}%\n" .
113 " \\lthtmldisplayA{#1}\\let\\\@eqnnum\\relax}%\n" .
114 "\\newcommand\\lthtmldisplayZ{\\lthtmlboxmathZ\\lthtmllogmath\\lthtmlsetmath}%\n" .
115 "\\newcommand\\lthtmlinlinemathA[1]{\\lthtmlmathtype{#1}\\lthtmlhboxmathA" .
116 " \\vrule height1.5ex width0pt }%\n" .
117 "\\newcommand\\lthtmlinlineA[1]{\\lthtmlmathtype{#1}\\lthtmlhboxmathA}%\n" .
118 "\\newcommand\\lthtmlinlineZ{\\egroup\\expandafter\\ifdim\\dp\\sizebox>0pt %\n" .
119 " \\expandafter\\centerinlinemath\\fi\\lthtmllogmath\\lthtmlsetinline}\n" .
120 "\\newcommand\\lthtmlinlinemathZ{\\egroup\\expandafter\\ifdim\\dp\\sizebox>0pt %\n" .
121 " \\expandafter\\centerinlinemath\\fi\\lthtmllogmath\\lthtmlsetmath}\n" .
122 "\\def\\lthtmlsetinline{\\hbox{\\vrule width.1em\\vtop{\\vbox{%\n" .
123 " \\kern.1em\\copy\\sizebox}\\ifdim\\dp\\sizebox>0pt\\kern.1em\\else\\kern.3pt\\fi\n" .
124 " \\ifdim\\hsize>\\wd\\sizebox \\hrule depth1pt\\fi}}}\n" .
125 "\\def\\lthtmlsetmath{\\hbox{\\vrule width.1em\\setbox1=\\vtop{\\vbox{%\n" .
126 " \\kern.1em\\kern$kern pt\\hbox{\\hglue.17em\\copy\\sizebox\\hglue$kern pt}}\\kern.3pt%\n" .
127 # " \\ifdim\\dp\\sizebox>0pt\\kern.1em \\kern$kern pt\\fi}%\n" .
128 " \\ifdim\\dp\\sizebox>0pt\\kern.1em\\fi \\kern$kern pt%\n" .
129 " \\ifdim\\hsize>\\wd\\sizebox \\hrule depth1pt\\fi}\\message{ht\\the\\ht1: dp\\the\\dp1}\\box1}}\n" .
130 "\\def\\centerinlinemath{%\\dimen1=\\ht\\sizebox\n" .
131 # " \\ifdim\\dimen1<\\dp\\sizebox \\ht\\sizebox=\\dp\\sizebox\n" .
132 " \\dimen1=\\ifdim\\ht\\sizebox<\\dp\\sizebox \\dp\\sizebox\\else\\ht\\sizebox\\fi\n" .
133 # " \\vrule width0pt depth\\dp\\sizebox \n" .
134 # " \\else \\dp\\sizebox=\\ht\\sizebox \\fi}\n\n" .
135 " \\advance\\dimen1by.5pt \\vrule width0pt height\\dimen1 depth\\dimen1 \n".
136 " \\dp\\sizebox=\\dimen1\\ht\\sizebox=\\dimen1\\relax}\n\n" .
137 "\\def\\lthtmlcheckvsize{\\ifdim\\ht\\sizebox<\\vsize\\expandafter\\vfill\n" .
138 " \\else\\expandafter\\vss\\fi}%\n" .
139 # "\\def\\\@enddocumenthook{\\ifnum\\count0>1 \\ifvoid\\\@cclv\\penalty-\\\@MM\\fi\\fi}\n" .
140 "\\makeatletter \\tracingstats = 1 \n" .
141 $LaTeXmacros . "\n" # macros defined in extension files
142 # "\\usepackage{lthimages}\n" .
143 . (($LATEX_DUMP)? "\\latexdump\n" : '')
144 . "\n\\begin{document}\n" .
145 "\\pagestyle{empty}\\thispagestyle{empty}%\n" .
146 "\\lthtmltypeout{latex2htmlLength hsize=\\the\\hsize}%\n" .
147 "\\lthtmltypeout{latex2htmlLength vsize=\\the\\vsize}%\n" .
148 "\\lthtmltypeout{latex2htmlLength hoffset=\\the\\hoffset}%\n" .
149 "\\lthtmltypeout{latex2htmlLength voffset=\\the\\voffset}%\n" .
150 "\\lthtmltypeout{latex2htmlLength topmargin=\\the\\topmargin}%\n" .
151 "\\lthtmltypeout{latex2htmlLength topskip=\\the\\topskip}%\n" .
152 "\\lthtmltypeout{latex2htmlLength headheight=\\the\\headheight}%\n" .
153 "\\lthtmltypeout{latex2htmlLength headsep=\\the\\headsep}%\n" .
154 "\\lthtmltypeout{latex2htmlLength parskip=\\the\\parskip}%\n" .
155 "\\lthtmltypeout{latex2htmlLength oddsidemargin=\\the\\oddsidemargin}%\n" .
156 "\\makeatletter\n" .
157 "\\if\@twoside\\lthtmltypeout{latex2htmlLength evensidemargin=\\the\\evensidemargin}%\n" .
158 "\\else\\lthtmltypeout{latex2htmlLength evensidemargin=\\the\\oddsidemargin}\\fi%\n" .
159 "\\makeatother\n"
160 . "$contents\n"
161 # "\\clearpage\n" .
162 . "\\end{document}";
163 }
164 $DONT_INCLUDE = "foilhtml:".$DONT_INCLUDE;
165 &ignore_commands( <<_IGNORED_CMDS_);
166 portraitfoils
167 lanscapefoils
168 MyLogo # {}
169 Restriction # {}
170 LogoOff
171 LogoOn
172 rightfooter # {}
173 rightheader # {}
174 leftheader # {}
175 newnonfloat #{} #{}
176 foilheadskip # &ignore_numeric_argument
177 abovefloatskip # &ignore_numeric_argument
178 captionwidth # &ignore_numeric_argument
179 titleauthorskip # &ignore_numeric_argument
180 authorauthorskip # &ignore_numeric_argument
181 authordateskip # &ignore_numeric_argument
182 dateabstractskip # &ignore_numeric_argument
183 zerolistvertdimens
184 _IGNORED_CMDS_
185 1; # This should be the last line