1% texinfo.t2p 2% Dorai Sitaram 3 4% This macro file is loaded by TeX2page when processing 5% Texinfo files. If the input document, say 6% jobname.texi, needs additional TeX2page-specific 7% macros, you may put them in jobname.t2p (as for input 8% documents in plain or LaTeX). If you wish to 9% redefine any of the macros already defined in 10% texinfo.t2p, you will need to explicitly \input 11% texinfo.t2p in jobname.t2p, _before_ the 12% redefinitions. Whether or not jobname.t2p explicitly 13% \inputs it, texinfo.t2p will be loaded by TeX2page 14% only once. If jobname.t2p does not exist, or if it 15% does _not_ explicitly \input texinfo.t2p, 16% jobname.texi will implicitly \input 17% texinfo.t2p where it tries to \input texinfo. 18 19% [SK] this is an attempt to make Dorai's tex2page work on 20% Gauche-ref?.texi. So far I haven't succeeded, but I put 21% this in CVS anyway to work in future. 22% $Id: texinfo.t2p,v 1.1 2004-02-02 11:43:01 shirok Exp $ 23 24\ifx\ifinfo\undefined 25\let\endloadingtexinfotiipnow\relax 26\else 27\let\endloadingtexinfotiipnow\endinput 28\message{texinfo.t2p already loaded} 29\fi 30\endloadingtexinfotiipnow 31 32\let\comment\TIIPcomment 33\let\c\comment 34\let\changepagesizes\c 35\let\internalpagesizes\c 36\let\setchapternewpage\c 37\let\setfilename\c 38%\let\settitle\c 39\let\headings\c 40\let\synindex\c 41\let\syncodeindex\c 42\let\footnotestyle\c 43\let\paragraphindent\c 44\let\dircategory\c 45\let\defcodeindex\c 46\let\shorttitlepage\c 47 48\def\settitle#1 49{\externaltitle{#1}} 50 51\def\.{.} 52 53%\let\contents\tableofcontents 54 55 56\def\contents{\evalh{ 57(toss-back-string "\\tableofcontents") 58(toss-back-string 59(if *using-chapters?* 60"\\NONTEXINFOchapter*{Contents}" 61"\\NONTEXINFOsection*{Contents}")) 62}} 63 64\def\titlefont#1{{\Huge #1}} 65 66%\def\titlepage{\let\pageOLD\page 67%\TIIPendgraf\begingroup\large 68%\def\page{\endgroup\pageOLD\titlepage}} 69% 70%\let\endtitlepage\endgroup 71 72 73\let\titlepage\relax 74\let\endtitlepage\relax 75 76\def\titlepage{\TIIPendgraf\begingroup\large} 77\let\endtitlepage\endgroup 78 79\evalh{(define *texinfo-values* '())} 80 81\def\setQii{% 82\evalh{ 83(let* ((var (get-peeled-group)) 84 (val (get-peeled-group))) 85 (set! *texinfo-values* 86 (cons (cons var val) *texinfo-values*))) 87}} 88 89\def\set#1 #2 90{\setQii{#1}{#2}} 91 92\def\value{% 93\evalh{ 94(let* ((var (get-peeled-group)) 95 (c (assoc var *texinfo-values*))) 96 (when c 97 (tex2page-string (cdr c)))) 98}} 99 100\let\NONTEXINFOend\end 101 102%\def\end#1 {\csname end#1\endcsname} 103 104\let\group\begingroup 105 106%\let\NONTEXINFOnode\node 107 108%\def\node#1 109%{\NONTEXINFOnode{#1}} 110 111\def\ignorespacestillnewlineinclusive{\evalh{ 112(let loop () 113 (let ((c (snoop-actual-char))) 114 (unless (eof-object? c) 115 (when (char-whitespace? c) 116 (get-actual-char) 117 (unless (char=? c #\newline) (loop)))))) 118}} 119 120\def\node{\evalh{ 121(let loop ((r '())) 122 (let ((c (snoop-actual-char))) 123 (cond ((or (char=? c #\,) 124 (char=? c #\return) 125 (char=? c #\newline)) 126 (if (char=? c #\,) (eat-till-eol)) 127 (set! *recent-node-name* 128 ;htmlize-label? 129 (list->string (reverse r)))) 130 (else (get-actual-char) (loop (cons c r)))))) 131}} 132 133\def\anchor#1{\tag{#1}{#1}} 134 135\def\menu{\iffalse} 136\def\endmenu{\fi} 137 138\def\macro{\iffalse} 139\def\endmacro{\fi} 140 141\def\direntry{\iffalse} 142\def\enddirentry{\fi} 143 144\def\ignore{\iffalse} 145\def\endignore{\fi} 146 147\def\ifinfo{\iffalse} 148\def\endifinfo{\fi} 149 150\def\ifnottex{\iffalse} 151\def\endifnottex{\fi} 152 153\let\ifhtml\htmlonly 154\let\endifhtml\endhtmlonly 155 156\let\html\rawhtml 157\let\endhtml\endrawhtml 158 159% 160 161\def\uref#1{\urefQii #1,,,\finish} 162 163\def\urefQii#1,#2,#3,#4\finish{% 164\def\urefQiii{#2}% 165\ifx\urefQiii\empty\url{#1}% 166\else\urlh{#1}{\urefQiii}\fi} 167 168% 169 170\let\include\input 171 172%\verbescapechar\\ 173\let\code\texttt 174\let\samp\texttt 175 176\def\xref{See \S\ref} 177 178\def\pxref{see \S\ref} 179 180\let\\\TIIPbackslash 181 182\let\dfn\textit 183\let\file\texttt 184\let\cite\textit 185\let\b\textbf 186\let\var\textit 187\let\t\texttt 188\let\sc\textsc 189\let\email\texttt 190\let\r\textrm 191 192% index 193 194\def\cindex#1 195{\index{#1}} 196 197\def\pindex#1 198{\index{#1@{\tt#1}}} 199 200\let\findex\pindex 201 202\let\kindex\pindex 203 204\let\vindex\pindex 205 206\let\opindex\index 207 208\let\cmindex\index 209 210\let\footnote\numfootnote 211 212\def\center#1 213{\centerline{#1}\TIIPnewline} 214 215\let\NONTEXINFOitem\item 216 217\let\TABLEitemstyle\relax 218 219\def\TABLEitem#1 220{\NONTEXINFOitem \TABLEitemstyle{#1}\break} 221 222\def\table#1 223{\begingroup\description 224\def\TABLEitemstyle{#1} 225\let\item\TABLEitem 226\let\itemx\TABLEitem 227} 228 229\def\endtable{\enddescription\endgroup} 230 231\let\ftable\table 232\let\endftable\endtable 233 234\let\multitable\table 235\let\endmultitable\endtable 236 237\def\sp#1 238{\par} 239 240\let\NONTEXINFOitemize\itemize 241 242\def\itemize#1 243{\NONTEXINFOitemize} 244 245\def\example{\par\TIIPendgraf\bgroup\tt\obeywhitespace\ignorespacestillnewlineinclusive} 246 247\def\endexample{\egroup\par} 248 249\let\lisp\example 250\let\endlisp\endexample 251 252\let\NONTEXINFOenumerate\enumerate 253\let\NONTEXINFOendenumerate\endenumerate 254\def\enumerate#1 255{\bgroup\NONTEXINFOenumerate 256\let\item\NONTEXINFOitem} 257 258\def\endenumerate{\NONTEXINFOendenumerate\egroup} 259 260\def\display#1 261{\par\bgroup\obeywhitespace} 262\def\enddisplay{\egroup\par} 263 264% 265 266\let\NONTEXINFOauthor\author 267\let\NONTEXINFOchapter\chapter 268\let\NONTEXINFOsection\section 269\let\NONTEXINFOsubsection\subsection 270\let\NONTEXINFOsubsubsection\subsubsection 271\let\NONTEXINFOappendix\appendix 272 273 274\let\page\eject 275 276\let\NONTEXINFOtitle\title 277 278\def\title#1 279{\NONTEXINFOtitle{#1}\hrule} 280 281\def\subtitle#1 282{\rightline{#1}} 283 284\newcount\authorcalled 285 286\def\author#1 287{\ifnum\authorcalled=0 288\bigskip\bigskip\bigskip 289\global\authorcalled=1 290\plainfootnote{\ }{} 291\fi 292\leftline{\bf#1}} 293 294\def\appendix{\NONTEXINFOappendix 295\let\NONTEXINFOappendix\relax 296\chapter} 297 298%\def\author#1 299%{\NONTEXINFOauthor{#1}} 300 301\let\top\title 302 303\def\chapter#1 304{\NONTEXINFOchapter{#1}\label{#1}} 305 306\def\unnumbered#1 307{\NONTEXINFOchapter*{#1}} 308 309\def\section#1 310{\NONTEXINFOsection{#1}\label{#1}} 311 312\def\unnumberedsec#1 313{\NONTEXINFOsection*{#1}} 314 315\def\subsection#1 316{\NONTEXINFOsubsection{#1}\label{#1}} 317 318\def\subsubsection#1 319{\NONTEXINFOsubsubsection{#1}\label{#1}} 320 321\def\appendixsec#1 322{\NONTEXINFOappendix\NONTEXINFOsection{#1}\label{#1}} 323 324\def\appendixsubsec#1 325{\NONTEXINFOappendix\NONTEXINFOsubsection{#1}\label{#1}} 326 327\def\appendixsubsubsec#1 328{\NONTEXINFOappendix\NONTEXINFOsubsubsection{#1}\label{#1}} 329 330\def\chapheading#1 331{\NONTEXINFOchapter*{#1}} 332\def\heading#1 333{\NONTEXINFOsection*{#1}} 334\def\subheading#1 335{\NONTEXINFOsubsection*{#1}} 336\def\subsubheading#1 337{\NONTEXINFOsubsubsection*{#1}} 338 339%only one index 340 341\def\printindex#1#2{ 342\def\printindex##1##2{} 343\NONTEXINFOchapter*{Index} 344{\let\end\NONTEXINFOend 345\inputindex}} 346 347\def\printindex#1#2{% 348\def\printindex##1##2{}% 349{\let\end\NONTEXINFOend 350\inputindex}} 351 352% is foll right? 353 354\def\iftex{\bgroup 355\def\tex{\fi\iftrue} 356\def\endtex{\fi\iffalse} 357\iffalse} 358\def\endiftex{\fi\egroup} 359 360% defun-type stuff 361\def\deffn#1#2 362{\rawhtml 363<pre>--#1--#2--</pre> 364\endrawhtml 365} 366 367\def\defun#1 368{\deffn {Function} #1 369} 370 371\evalh{ 372(set! *tex-format* 'texinfo) 373 374(define *texi-file-suffix* "-Z-T-") 375(define *texi-file-count* 0) 376 377(define texi-to-tex 378 (lambda (f) 379 (write-log 'separation-space) (write-log #\{) 380 (write-log f) (write-log 'separation-space) (write-log "->") 381 (write-log 'separation-space) 382 (set! *texi-file-count* (+ *texi-file-count* 1)) 383 (let ((fo (string-append *aux-dir/* *jobname* *texi-file-suffix* 384 (number->string *texi-file-count*) ".tex"))) 385 (ensure-file-deleted fo) 386 (write-log fo) 387 ;this makes tex2page not read past newline 388 ;when eating whitespace 389 (call-with-input-file/buffered 390 f 391 (lambda () 392 (call-with-output-file fo 393 (lambda (o) 394 (fluid-let ((*not-processing?* #t) 395 (*esc-char* #\@)) 396 (let loop () 397 (let ((c (snoop-actual-char))) 398 (unless (eof-object? c) 399 (cond ((char=? c #\@) 400 (let ((x (get-ctl-seq))) 401 (display x o) 402 (cond ((string=? x "\\tex") (dump-till-end-tex o)) 403 ((string=? x "\\end") (ignorespaces))) 404 (loop))) 405 ((ormap (lambda (x) (char=? c x)) 406 '(#\\ #\% #\$ #\#)) 407 (get-actual-char) 408 (write-char #\\ o) (write-char c o) (loop)) 409 (else (get-actual-char) 410 (write-char c o) (loop))))))))))) 411 (write-log #\}) 412 (write-log 'separation-space) 413 fo))) 414 415(define dump-till-end-tex 416 (lambda (o) 417 (let loop () 418 (let ((c (snoop-actual-char))) 419 (cond ((eof-object? c) (terror 'dump-till-end-tex)) 420 ((char=? c #\@) 421 (let ((x (get-ctl-seq))) 422 (cond ((string=? x "\\end") 423 (ignorespaces) 424 (toss-back-string "@end") 425 (set! x (get-ctl-seq)) 426 (display x o) 427 (unless (string=? x "\\endtex") 428 (loop))) 429 ((string=? x "\\comment") 430 (write-char #\% o) (newline o) 431 (eat-till-eol) (loop)) 432 (else (display x o) 433 (loop))))) 434 (else (get-actual-char) 435 (write-char c o) 436 (loop))))))) 437 438(set! tex2page-massage-file 439 (lambda (f) 440 (let ((e (file-extension f))) 441 (cond ((and e (member/string-ci=? 442 e '(".t2p" ".ind" ".bbl"))) 443 (deactivate-cdef #\newline) 444 f) 445 (else (tex-def-char #\newline '() "\\TIIPnewline" #f) 446 (texi-to-tex f)))))) 447 448 449} 450 451\let\backslash\\ 452 453\def\\input texinfo{% 454%\csname Texinfohook\endcsname 455\global\let\\\backslash} 456 457