Debian Codegraph @

texmf-dist/source/generic/tex4ht/wripro.tex

raw
1 % $Id: wripro.tex 1558 2024-09-24 17:22:45Z karl $
2 % Used in tex4ht.sty. Not installed in runtime.
3 %
4 % Copyright 2009-2024 TeX Users Group
5 % Copyright 1996-2009 Eitan M. Gurari
6 %
7 % This work may be distributed and/or modified under the
8 % conditions of the LaTeX Project Public License, either
9 % version 1.3c of this license or (at your option) any
10 % later version. The latest version of this license is in
11 % http://www.latex-project.org/lppl.txt
12 % and version 1.3c or later is part of all distributions
13 % of LaTeX version 2005/12/01 or later.
14 %
15 % This work has the LPPL maintenance status "maintained".
16 %
17 % The Current Maintainer of this work
18 % is the TeX4ht Project <http://tug.org/tex4ht>.
19 %
20 % If you modify this program, changing the
21 % version identification would be appreciated.
22 \immediate\write-1{version 2024-09-23-15:43}
23
24 %\openin15= wripro.tex
25 %\ifeof15 \closein15 \else \closein15 \input wripro.tex \fi
26
27
28
29 \Section{Root Point}
30
31 \<html TeX4ht protex\><<<
32 \ifx\html:addr\:UnDeF
33 |<html common to TeX4ht and protex|>
34 \Htmltrue
35 \fi
36 >>>
37
38 \ifalprotex
39
40 \<html+nohtml protex\><<<
41 |<new ifs|>
42 |<html+nohtml common to TeX4ht and protex|>
43 |<nohtml common to TeX4ht and protex|>
44 >>>
45
46 \fi
47
48 \<non-html utilities\><<<
49 |<nohtml common to TeX4ht and protex|>
50 >>>
51
52
53 \SubSection{Directory for Files}
54
55 \<html common to TeX4ht and protex\><<<
56 \writesixteen{--- needs --- tex4ht \jobname\space ---}%
57 >>>
58
59
60
61
62 \<html common to TeX4ht and protexNO\><<<
63 \ifx\HDir\:UnDef \let\HDir=\empty \fi
64 \let\:HDir=\HDir
65 \immediate\write16{--- needs --- TeX4ht \ifx\HDir\empty
66 \else-d \HDir\space\space\fi \jobname\space ---}%
67 >>>
68
69
70 \SubSection{Identifiers and Counters}
71
72
73 \<new ifs\><<<
74 \ifx \Htmltrue\:UnDef
75 \def\:temp{\csname newif\endcsname}
76 \expandafter\:temp \csname ifHtml\endcsname \Htmlfalse
77 \fi
78 >>>
79
80
81 \<html common to TeX4ht and protex\><<<
82 \ifx\tmp:cnt\:UnDeF \csname newcount\endcsname\tmp:cnt \fi
83 \def\g:advance#1{\bgroup \def\:temp{#1}%
84 \tmp:cnt=#1\afterassignment\:gplus \advance\tmp:cnt}
85 \def\:gplus{\expandafter\xdef\:temp{\the\tmp:cnt}\egroup}
86 \def\html:lbl{1}
87 \def\html:addr{\xdef\last:haddr{\file:id-\html:lbl}%
88 \g:advance\html:lbl by 1\relax }
89 >>>
90
91 \<html common to TeX4ht and protex\><<<
92 \ifx \file:id\:UnDef
93 \gdef\file:id{|<first file id|>}
94 \global\let\maxfile:id=\file:id
95 \fi
96 >>>
97
98 \<first file id\><<<
99 1>>>
100
101
102
103 \SubSection{Relax Right Margin}
104
105 \<html common to TeX4ht and protex\><<<
106 \hbadness=10000 \vbadness=10000
107 \:CheckOption{fussy} \if:Option \else
108 \hfuzz=99in \vfuzz=\hfuzz
109 \fi
110 \hyphenpenalty=1000 \exhyphenpenalty=1000
111 \def\html:rightskip{\rightskip = 0pt plus 0.5\hsize minus0.5\hsize }
112 \html:rightskip
113 >>>
114
115
116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117 \SubSection{Foot and Head Lines}
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
119
120 % \<html common to TeX4ht and protex\><<<
121
122 \<html protex\><<<
123 \ifx \footline\:UnDef \else
124 \footline={\hfil} \headline={\hfil}
125 \fi
126 >>>
127
128
129 \Section{Html Commmands From Users}
130
131 The \''\let\ht:special=\special' is for protection
132 against redefinitions of the \''\special', as is the case in french.sty.
133
134
135 \<html common to TeX4ht and protex\><<<
136 \ifx \ht:special\:UnDef
137 \let\ht:special=\special
138 \fi
139 \def\HCode#1{\ifx \EndPicture\:UnDef
140 \relax\ifvmode\leavevmode\fi\ht:special{t4ht=#1}\fi}
141 \let\:HCode=\HCode
142 \let\Hbrakets\empty
143 \def\NewLineChar{\bgroup \catcode`\^=7 \:NewLineChar}
144 \def\:NewLineChar#1{\egroup \def\:newlnch{ #1}}
145 \NewLineChar{^^J}
146 >>>
147
148
149 \<nohtml common to TeX4ht and protex\><<<
150 \def\HCode#1{}
151 >>>
152
153 The \`+\HCode+' starts a new paragraph if introduced in vertical mode.
154 The \`+\leavevmode+' is included for proper spacing in dviht.
155
156
157
158 \Section{Cross References within Html}
159
160 - NCSA Mosaic can't handle the
161 end-of-anchor {\tt</...>} tag if it is not on one line.
162 For instance, in {\tt
163 <A>...<A\vfil\break>},
164 Mosaic paints everything blue until the next {\tt </A> }it finds that is
165 entirely on one line.
166
167 \<html+nohtml common to TeX4ht and protex\><<<
168 \def\EndLink{\ifx \empty:lnk\empty \HCode{\Hbrakets</\tag:A>}\fi}
169 \def\:HRef{\ifx [\:temp \expandafter\::HRef
170 \else \expandafter\:::HRef \fi }
171 \def\HT:tag{\ifx -\let:val \expandafter\H:Tag
172 \else \expandafter\HTa:g\fi }
173 \def\HTa:g{\H:Tag-}
174 \def\Link{\let\:attr\empty \futurelet\let:val\HRefT:ag}
175 \def\HRefT:ag{\ifx -\let:val \expandafter\H:RefTag
176 \else \expandafter\HRefTa:g\fi }
177 \def\HRefTa:g{\H:RefTag-}
178 \def\H:RefTag#1{\futurelet\:temp\:HRefTag}
179 \def\:HRefTag{\ifx [\:temp \expandafter\::HRefTag
180 \else \expandafter\:::HRefTag \fi }
181 >>>
182
183
184 A \`'\Link-{..}{b}' asks that a \''\Tag' will not be produced for `b'.
185 A \`'\Link[\empty]{b}{..}' asks that a \''\XRef' will not be produced for
186 `a'. The same is true for any other non-empty replacement to \''\empty'
187 A `b' for which we neither have a \''\Tag' and a \''\XRef' provides
188 a memory save in `strings out of', `string characters out of', and
189 `multiletter control sequences' (see log files).
190
191 \<html common to TeX4ht and protex\><<<
192 \def\::HRef[#1]{\get:attr{#1}\::hRef\:::HRef}
193 \def\::HRefTag[#1]{\get:attr{#1}\::hRefTag\:::HRefTag}
194 \def\get:attr#1{\edef\:attr{\noexpand\get:atr #1 |<par del|>}\:attr}
195 \def\get:atr#1 #2|<par del|>#3#4{\def\:attr{\space#2}%
196 \def\:te:mpa{#1}\ifx \:te:mpa\empty \let\:te:mpa#4\else
197 \def\:te:mpa{#3[#1]}\fi \:te:mpa}
198 >>>
199
200
201 \<html common to TeX4ht and protex\><<<
202 \def\H:Tag#1#2{\:TagHTag{#2}\HCode{\Hbrakets<\tag:A\:newlnch
203 \NAME:"#2"\empty:lnk>}}
204 \def\::hRef[#1]#2{%
205 \HCode{\Hbrakets<\tag:A\:newlnch \if\relax#1#2\relax \NOHREF:{}\else
206 \HREF:"#1\if\relax#1\relax \else\:sharp #2\fi"\fi
207 \:attr \empty:lnk>}}
208 \def\:::HRef#1{%
209 \HCode{\Hbrakets<\tag:A\:newlnch \if\relax#1\relax \NOHREF:{}\else
210 \HREF:"\get:hfile{#1}\:sharp #1"\fi \:attr \empty:lnk>}}
211 >>>
212
213
214
215 \<\><<<
216 \def\::hRef[#1]#2{\def\:te:mp{#1}\def\:te:mpa{#1#2}%
217 \HCode{<\tag:A\:newlnch \ifx\:te:mpa\empty \NOHREF: \else
218 \HREF:"#1\ifx\:te:mp\empty \else\:sharp #2\fi"\fi
219 \:attr \empty:lnk>}}
220 \def\:::HRef#1{\def\:te:mpa{#1}%
221 \HCode{<\tag:A\:newlnch \ifx\:te:mpa\empty \NOHREF: \else
222 \HREF:"\get:hfile{#1}\:sharp #1"\fi \:attr \empty:lnk>}}
223 >>>
224
225
226
227
228 \<html common to TeX4ht and protex\><<<
229 \def\::hRefTag[#1]#2#3{%
230 \if\relax#3\relax\else\:TagHTag{#3}\fi
231 \HCode{\Hbrakets<\tag:A\:newlnch \if\relax#1#2\relax \NOHREF:{#3}\else
232 \HREF:"#1\if\relax#2\relax \else\:sharp #2\fi"\fi
233 \if\relax#3\relax\else\space \NAME:"#3"\fi
234 \:attr \empty:lnk>}}
235 \def\:::HRefTag#1#2{%
236 \if\relax#2\relax\else\:TagHTag{#2}\fi
237 \HCode{\Hbrakets<\tag:A\:newlnch \if\relax#1\relax \NOHREF:{#2}%
238 \else\HREF:"\get:hfile{#1}\:sharp #1"\fi
239 \if\relax#2\relax\else\space \NAME:"#2"\fi
240 \:attr \empty:lnk>}}
241 \let\empty:lnk=\empty
242 \def\NOHREF#1{\space}
243 >>>
244
245 \<\><<<
246 \def\::hRefTag[#1]#2#3{\def\:te:mp{#2}\def\:te:mpa{#1#2}\def\:te:mpb{#3}%
247 \ifx\:te:mpb\empty\else\:TagHTag{#3}\fi
248 \HCode{<\tag:A\:newlnch \ifx\:te:mpa\empty \NOHREF: \else
249 \HREF:"#1\ifx\:te:mp\empty \else\:sharp #2\fi"\fi
250 \ifx\:te:mpb\empty\else\space \NAME:"#3"\fi
251 \:attr \empty:lnk>}}
252 \def\:::HRefTag#1#2{\def\:te:mp{#1}\def\:te:mpa{#2}%
253 \ifx\:te:mpa\empty\else\:TagHTag{#2}\fi
254 \HCode{<\tag:A\:newlnch \ifx\:te:mp\empty \NOHREF:
255 \else\HREF:"\get:hfile{#1}\:sharp #1"\fi
256 \ifx\:te:mpa\empty\else\space \NAME:"#2"\fi
257 \:attr \empty:lnk>}}
258 >>>
259
260
261
262
263
264
265
266 \''\def\NOHREF:#1{\ifx \hrEF:\HREF: \space NOHREF \fi}' is not part of html!
267
268 \<html protex\><<<
269 \def\HREF:{ href=}
270 \def\tag:A{a}
271 \def\NAME:{ name=}
272 >>>
273
274
275 % \let\hrEF:=\HREF:
276
277
278 We don't use \`'^^J' to break lines in \''\write' because user may
279 change it, and because I had unexplained problem with it in emtex.
280
281 \<html common to TeX4ht and protex\><<<
282 \def\:TagHTag#1{\ifx -\let:val\else \Tag{|<HTag tag|>#1}{\file:id}\fi}
283 >>>
284
285 \<nohtml common to TeX4ht and protex\><<<
286 \def\H:Tag#1#2{}
287 \def\::HRef[#1]#2{}
288 \def\:::HRef#1{}
289 \def\::HRefTag[#1]#2#3{}
290 \def\:::HRefTag#1#2{}
291 \def\:TagHTag#1{}
292 >>>
293
294
295
296
297 \Section{Html Addresses}
298
299 \SubSection{Retrieving for HREF}
300
301 \<html common to TeX4ht and protex\><<<
302 \def\get:href{\expandafter\get::href}
303 \def\get::href#1-#2-{\ifnum #1=\file:id\space \else
304 |<get html file name|>\fi
305 \:sharp |<make html addr|>}
306 >>>
307
308
309
310 \<html common to TeX4ht and protexNO\><<<
311 \def\get:href{\expandafter\get::href}
312 \def\get::href#1-#2-{\ifnum #1=\file:id\space \else
313 \:HDir |<get html file name|>\fi
314 \:sharp |<make html addr|>}
315 >>>
316
317 \SubSection{Retrieving for NAME}
318
319 \<html common to TeX4ht and protex\><<<
320 \def\get:htag{\expandafter\get::htag}
321 \def\get::htag#1-#2-{|<make html addr|>}
322 >>>
323
324
325 \SubSection{Generating}
326
327 \<make html addr\><<<
328 \make:addr{#2}>>>
329
330 \<html protex\><<<
331 \def\make:addr#1{%
332 \ifnum\clearcode:id>0 \romannumeral\clearcode:id Q\else PrTx\fi
333 |<tail for file name|>#1}
334 \ifx\clearcode:id\:UnDef
335 \def\clearcode::id{0} \def\clearcode:id{0}
336 \fi
337 >>>
338
339 We had before \`'\space' after \`'#1'. It was not a problem because
340 \`'|<tail...' was a \''\roman..' that absorbed the space. But
341 now with no one absorbing it, it became a problem.
342
343
344 \<html protexNO\><<<
345 \def\make:addr#1{%
346 \ifnum\clearcode:id>0 \romannumeral\clearcode:id Q\fi
347 |<tail for file name|>#1\space}
348 \ifx\clearcode:id\:UnDef
349 \def\clearcode::id{0} \def\clearcode:id{0}
350 \fi
351 >>>
352
353
354
355
356 \<tail for file name\><<<
357 >>>
358
359 Originally, we had \`'\romannumeral' for tail, but it created named
360 that are too long, and cause memory overflow.
361
362
363 The condition \`'\ifnum\clearcode:id>0' is set to hold only for
364 references to code fragments.
365
366 Romannumeral might be better tags then just numerals because they
367 might be less likely to be generater manually.
368
369 \SubSection{File Names}
370
371
372 \`=\Ref= and \`=\Tag= are mechanisms to exchange information. The
373 following can be used to connect locations. (Note, however, that
374 \`=\Tag= may appear in more than one location sending a sequences of tags
375 separated by comma. In such cases, we arbitrarily go for the first
376 choise.)
377
378
379 \<init XrefFile\><<<
380 \ifx \aXrefFile\:UnDef \let\aXrefFile=\empty \fi
381 >>>
382
383
384 \<html common to TeX4ht and protex\><<<
385 |<init XrefFile|>
386 \def\get:hfile#1{%
387 \expandafter\ifx\csname
388 |<tag of Tag|>|<HTag tag|>#1\endcsname\relax
389 \get@hfile{#1}%
390 \else
391 \expandafter\expandafter\expandafter\get::hfile
392 \csname |<tag of Tag|>|<HTag tag|>#1\endcsname,//%
393 \fi }
394 \def\get::hfile#1,#2//{%
395 \ifnum \file:id=0#1 \else
396 |<get file name for tag|>%
397 \fi }
398 \ifx\get@hfile\:Undef \let\get@hfile=\:gobble \fi
399 >>>
400
401
402 \<get file name for tag\><<<
403 \expandafter\ifx
404 \csname |<tag of Tag|>|<auto file tag|>#1%
405 |<Tag/Ref: file-id -> file-name|>\endcsname\relax \else
406 \:LikeRef{|<auto file tag|>#1|<Tag/Ref: file-id -> file-name|>}%
407 \fi >>>
408
409
410 \<get file name for tagNO\><<<
411 \expandafter\ifx
412 \csname |<tag of Tag|>|<auto file tag|>#1%
413 |<Tag/Ref: file-id -> file-name|>\endcsname\relax \else
414 \:HDir \:LikeRef{|<auto file tag|>#1|<Tag/Ref: file-id -> file-name|>}%
415 \fi >>>
416
417
418
419 \<get html file name\><<<
420 \:LikeRef{|<auto file tag|>#1|<Tag/Ref: file-id -> file-name|>}>>>
421
422
423 The following alternative can act as basis for retrieving all
424 the file names, instead of just the first one.
425
426 \<COMMENT\><<<
427 \def\get:hfile#1{%
428 \expandafter\ifx\csname
429 cw:|<HTag tag|>#1\endcsname\relax
430 \get@hfile{#1}%
431 \else
432 \expandafter\expandafter\expandafter\get::hfile
433 \csname cw:|<HTag tag|>#1\endcsname,\empty end:Links,/
434 \fi }
435 \def\end:Links#1//{}
436
437 \def\get::hfile#1,#2//{%
438 \expandafter \ifx \csname #1\endcsname\end:Links
439 \expandafter\end:Links
440 \else
441 \ifnum \file:id=0#1 \FileName\else
442 \expandafter\ifx
443 \csname cw:|<auto file tag|>#1%
444 \empty F-\endcsname\relax \else
445 \:LikeRef{|<auto file tag|>#1\empty F-}%
446 \fi %
447 \fi
448 \expandafter\get::hfileA
449 \fi #2//}
450
451 \def\get::hfileA#1{%
452 \ifx #1\space
453 \expandafter\get::hfile\else
454 \ifx #1\empty \else \space\fi%
455 \expandafter\get::hfile\expandafter#1\fi}
456 >>>
457
458
459
460
461 \Section{Other}
462
463
464 Dviht produce new line only after nonempty lines. The following
465 can be used to force non empty lines.
466
467 \<html common to TeX4ht and protex\><<<
468 |%\def\HComment#1{\def\html:src{#1}}
469 \HComment{} |% \let\html:src=\empty
470 \catcode`\#=12 \def\:sharp{#} \catcode`\#=6
471 >>>
472
473
474
475
476 \<html protex\><<<
477 \ifx \html:par\:UnDef \def\html:par{\HCode{<p>}} \fi
478 \def\html:invisible{<!--x-->\string&\#x00A0;}
479 >>>
480
481 The \`'<!--x-->&nbsp;' is needed for blank lines in \`'<PRE>'
482 within netscape. Opposite order of comment and non-breaking-space will
483 not work, and the same if one of the entities is sliminates. On the
484 other other, mosaic show the nobreaking space as strin. Well, ...
485
486 \<nohtml common to TeX4ht and protex\><<<
487 |%\def\HComment#1{}|%
488 >>>
489
490 \`'\HComment' seems to have no real value, unless we want to
491 trace the input for debugging.
492
493
494 \SubSection{Tags}
495
496 \FreeCode\<tag of Tag\> % to ensure agains duplication
497
498 \<tag of Tag\><<<
499 cw:>>>
500
501 \<HTag tag\><<<
502 |<auto tag|>Q\aXrefFile >>>
503
504
505
506 \<Tag/Ref: file-id -> file-name\><<<
507 \empty F->>>
508
509 \<auto tag\><<<
510 )>>>
511
512 \<auto file tag\><<<
513 |<auto tag|>F\aXrefFile >>>
514
515
516 \FreeCode\<par del\>
517
518 \<par del\><<<
519 !*?: >>>