├── .tex2page.hdir
├── texinfo.t2p
├── scmxlate-skip-lines-tex2page.rkt
├── dialects
├── files-to-be-ported.scm
├── operating-systems-supported.scm
├── petite-tex2page.rkt
├── other-tex2page.rkt
├── cyclone-tex2page.rkt
├── ypsilon-tex2page.rkt
├── chibi-tex2page.rkt
├── rscheme-tex2page.rkt
├── umbscheme-tex2page.rkt
├── ikarus-tex2page.rkt
├── temp-file.scm
├── with-port.scm
├── dialects-supported.scm
├── stk-tex2page.rkt
├── plt-common-tex2page.scm
├── string-ports.scm
├── fake-strftime.scm
├── kawa-tex2page.rkt
├── racket-tex2page.rkt
├── mitscheme-tex2page.rkt
├── mzscheme-tex2page.rkt
├── sxm-tex2page.rkt
├── guile-tex2page.rkt
├── pscheme-tex2page.rkt
├── plt-tex2page.rkt
├── stklos-tex2page.rkt
├── scm-tex2page.rkt
├── chez-tex2page.rkt
├── gauche-tex2page.rkt
├── gambit-tex2page.rkt
├── seconds-to-date.scm
├── chicken-tex2page.rkt
├── make-guile-version
├── scheme48-tex2page.rkt
├── scsh-tex2page.rkt
├── bigloo-tex2page.rkt
└── cl-tex2page.rkt
├── t2p-example
├── guile.t2p
├── slatxdoc.t2p
├── osdwcvs.t2p
├── chicken.t2p
├── btxdoc.t2p
├── sicp-css.t2p
├── eplain.t2p
├── scshdoc.tex
├── man.t2p
├── scsh-paper.t2p
├── r7rs.t2p
├── r5rs.t2p
└── book.t2p
├── cliiscm-files-to-be-ported.lisp
├── t2p.png
├── tbdek.jpg
├── tex2page.bat
├── mpexample.tex
├── story.hlog
├── tex2page.sty
├── COPYING
├── README.adoc
├── scmxlate-tex2page.rkt
├── celeb.tex
├── .gitignore
├── defun.tex
├── texample.tex
├── slidecss.tex
├── story.log
├── ursa-major.tex
├── texrc.tex
├── tgtermes.tex
├── 2col.tex
├── tex2pagerc.tex
├── like-plt-logo.tex
├── coloraug.tex
├── eval4tex.tex
├── colormodels.lua
├── faq.tex
├── tex2page-doc-mac.tex
├── colorxe.tex
├── man
└── man1
│ └── tex2page.1
├── INSTALL.adoc
├── tex2pagedeprecated.tex
├── configure
├── plainsection.tex
├── texi2p.tex
└── cliiscm-tex2page.lisp
/.tex2page.hdir:
--------------------------------------------------------------------------------
1 | docs
2 |
--------------------------------------------------------------------------------
/texinfo.t2p:
--------------------------------------------------------------------------------
1 | \input texi2p
2 |
--------------------------------------------------------------------------------
/scmxlate-skip-lines-tex2page.rkt:
--------------------------------------------------------------------------------
1 | 3
2 |
--------------------------------------------------------------------------------
/dialects/files-to-be-ported.scm:
--------------------------------------------------------------------------------
1 | tex2page.rkt
2 |
--------------------------------------------------------------------------------
/t2p-example/guile.t2p:
--------------------------------------------------------------------------------
1 | \let\page\relax
2 |
3 |
--------------------------------------------------------------------------------
/cliiscm-files-to-be-ported.lisp:
--------------------------------------------------------------------------------
1 | tex2page.lisp
2 |
--------------------------------------------------------------------------------
/dialects/operating-systems-supported.scm:
--------------------------------------------------------------------------------
1 | unix
2 | windows
3 |
--------------------------------------------------------------------------------
/t2p.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ds26gte/tex2page/master/t2p.png
--------------------------------------------------------------------------------
/tbdek.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ds26gte/tex2page/master/tbdek.jpg
--------------------------------------------------------------------------------
/tex2page.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | d:\plt\racket -qvm -f d:\public_html\tex2page\tex2page.rkt -C %0 %1
3 |
--------------------------------------------------------------------------------
/dialects/petite-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ;last change: 2017-01-01
2 |
3 | (scmxlate-include "chez-tex2page.rkt")
4 |
--------------------------------------------------------------------------------
/mpexample.tex:
--------------------------------------------------------------------------------
1 | \input tex2page
2 |
3 | \beginsection Listing of file \p{lambda.mp}
4 |
5 | \verbatiminput lambda.mp
6 |
7 | \bye
8 |
--------------------------------------------------------------------------------
/dialects/other-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change: 2003-06-21
2 |
3 | (scmxlate-ignore
4 | main)
5 |
6 | (scmxlate-uncall
7 | require
8 | ;main
9 | )
10 |
11 |
--------------------------------------------------------------------------------
/story.hlog:
--------------------------------------------------------------------------------
1 | This is TeX2page, Version 20170129 (ECL 16.1.3 Linux) Sun, Jan 29, 2017, 1:53 am UTC−5
2 | (story.tex)
3 | ! Missing \end inserted.
4 | [0]
5 | Output written on story.html (1 page).
6 |
--------------------------------------------------------------------------------
/tex2page.sty:
--------------------------------------------------------------------------------
1 | % tex2page.sty
2 | % Dorai Sitaram
3 |
4 | % Loading this file in a LaTeX document
5 | % gives it all the macros of tex2page.tex,
6 | % but via a more LaTeX-convenient filename.
7 |
8 | \input{tex2page}
9 |
10 |
--------------------------------------------------------------------------------
/dialects/cyclone-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change: 2023-01-01
2 |
3 | (scmxlate-uncall
4 | define-namespace-anchor
5 | require
6 | )
7 |
8 | (scmxlate-ignoredef
9 | *tex2page-namespace*
10 | )
11 |
12 | (define *scheme-version* "Cyclone")
13 |
--------------------------------------------------------------------------------
/dialects/ypsilon-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ;last change 2009-04-10
2 |
3 | ;fails to read long strings. Splitting the string doesn't seem to help
4 |
5 | (scmxlate-uncall
6 | require)
7 |
8 | (define *scheme-version*
9 | "Ypsilon")
10 |
11 | ; vi:ft=lisp
12 |
13 |
--------------------------------------------------------------------------------
/dialects/chibi-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ;last modified 2022-12-28
2 |
3 | ;TBD
4 |
5 | (scmxlate-uncall
6 | define-namespace-anchor
7 | require
8 | )
9 |
10 | (define *scheme-version*
11 | "Chibi")
12 |
13 | (define *tex2page-namespace* (interaction-environment))
14 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | Copyright (c) 1997-2019, Dorai Sitaram.
2 | All rights reserved.
3 |
4 | Permission to distribute and use this work for any
5 | purpose is hereby granted provided this copyright
6 | notice is included in the copy. This work is provided
7 | as is, with no warranty of any kind.
8 |
--------------------------------------------------------------------------------
/README.adoc:
--------------------------------------------------------------------------------
1 | = TeX2page
2 |
3 | TeX2page is a Scheme or Common Lisp program for making Web pages
4 | from (La)TeX documents.
5 |
6 | Please see http://ds26gte.github.io/tex2page/index.html for what
7 | it can do.
8 |
9 | Installation instructions are at link:INSTALL.adoc[].
10 |
--------------------------------------------------------------------------------
/dialects/rscheme-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change: 2003-06-21
2 |
3 | (scmxlate-insert
4 | "\":\";echo '"
5 | "(define arg-one \"'$1'\")"
6 | "(load \"'$0'\")"
7 | "(main (list 1 arg-one))"
8 | "(exit)"
9 | "'|exec rs; exit"
10 | "\n\n")
11 |
12 | (scmxlate-uncall
13 | require
14 | )
15 |
16 |
17 |
--------------------------------------------------------------------------------
/dialects/umbscheme-tex2page.rkt:
--------------------------------------------------------------------------------
1 | (define *scheme-version* "UMB Scheme")
2 |
3 | (scmxlate-uncall
4 | require)
5 |
6 |
7 | (define getenv
8 | (lambda (envvar)
9 | #f))
10 |
11 | (defmacro unless (b . ee)
12 | `(if (not ,b) (begin ,@ee)))
13 |
14 | (defmacro when (b . ee)
15 | `(if ,b (begin ,@ee)))
16 |
--------------------------------------------------------------------------------
/scmxlate-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ;last modified 2017-01-01
2 |
3 | (scmxlate-postprocess
4 | (scmxlate-system "cp -p my-tex2page.rkt my-tex2page")
5 | (scmxlate-system "chmod +x my-tex2page")
6 | (scmxlate-system "rm -f tex2page my-tex2page.rkt")
7 | (scmxlate-system "cp -p my-tex2page tex2page")
8 | (scmxlate-system "chmod +x tex2page"))
9 |
--------------------------------------------------------------------------------
/dialects/ikarus-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change 2012-04-21
2 |
3 | (scmxlate-uncall
4 | require
5 | )
6 |
7 | (define eval1
8 | (lambda (e)
9 | (eval e (scheme-report-environment 5))))
10 |
11 | (define *scheme-version*
12 | "Ikarus Scheme")
13 |
14 |
15 |
16 | (define main
17 | (lambda ()
18 | (tex2page (car (command-line)))))
19 |
--------------------------------------------------------------------------------
/dialects/temp-file.scm:
--------------------------------------------------------------------------------
1 | ;created < 2014-08-21
2 | ;last modified 2022-12-26
3 |
4 | (define make-temp-filename
5 | (let ((n 0))
6 | (lambda ()
7 | (set! n (+ n 1))
8 | (let ((f (string-append "Scheme_Temp_file_"
9 | (number->string n))))
10 | (if (file-exists? f)
11 | ;try again
12 | (make-temp-filename)
13 | f)))))
14 |
--------------------------------------------------------------------------------
/t2p-example/slatxdoc.t2p:
--------------------------------------------------------------------------------
1 | \cssblock
2 | .scheme .variable {
3 | font-style: italic;
4 | }
5 |
6 | \endcssblock
7 |
8 | % Redefine \section so that it starts a fresh page
9 |
10 | \let\ORIGsection\section
11 | \def\section{\vfill\eject\ORIGsection}
12 |
13 | \imgpreamble
14 | \input slatex.sty
15 | \endimgpreamble
16 |
17 | \scmkeyword{setq}
18 | \scmspecialsymbol{$B$}{{\em B}}
19 |
20 |
--------------------------------------------------------------------------------
/celeb.tex:
--------------------------------------------------------------------------------
1 | \input texrc
2 | \input btxmac
3 |
4 | \title{Some \TeX2page examples}
5 |
6 | %\nocite{chicken-manual}
7 | \nocite{htdp,sicp,sicm,r5rs,r6rs,r6rs-lib,r6rs-app,r6rs-rationale,r7rs,scsh-paper,scsh-man,s48manual}
8 |
9 | \bibliographystyle{plain}
10 | \bibliography{tex2page}
11 |
12 | %(\urlh{t2p-example/scshdoc.html}{Instructions}
13 | %for generating the HTML versions of the Scsh
14 | %documents~\cite{scsh-paper,scsh-man}.)
15 |
16 | \bye
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | Makefile
2 | *.JPG
3 | *.aux
4 | *.bbl
5 | *.blg
6 | *.def
7 | *.eps
8 | *.mp
9 | *.mpx
10 | *.new
11 | *.old
12 | *.pdf
13 | *.rdb
14 | *.sav
15 | *.tem
16 | *.toc
17 | *.txt
18 | *.typ
19 | *.xcf
20 | *.xrf
21 | *~
22 | .scmport*
23 | #?
24 | #?.*
25 | #??.*
26 | #???
27 | [^2cdefilmpstu]*.tex
28 | [^IR]*.adoc
29 | [^ct]*.lisp
30 | [^s]*log
31 | eg
32 | example
33 | index-Z*.tex
34 | lambda*
35 | my-tex2page*
36 | ossuary/*
37 | tmp/*
38 | *Z-[AIL]*
39 | z*
40 |
--------------------------------------------------------------------------------
/dialects/with-port.scm:
--------------------------------------------------------------------------------
1 | (define with-output-to-port
2 | (lambda (o th)
3 | (let* ((f (make-temp-filename))
4 | (r (with-output-to-file f th)))
5 | (call-with-input-file f
6 | (lambda (i)
7 | (let loop ()
8 | (let ((c (read-char i)))
9 | (if (not (eof-object? c))
10 | (begin
11 | (write-char c o)
12 | (loop)))))))
13 | (delete-file f)
14 | r)))
15 |
--------------------------------------------------------------------------------
/defun.tex:
--------------------------------------------------------------------------------
1 | % last modified 2018-06-09
2 |
3 | % definitions (useful in reference manuals)
4 |
5 | \def\defun#1{\def\defuntype{#1}%
6 | \medbreak
7 | \line\bgroup
8 | \hbox\bgroup
9 | \aftergroup\enddefun
10 | \vrule width .5ex \thinspace
11 | \vrule \enspace
12 | \vbox\bgroup\setbox0=\hbox{\defuntype}%
13 | \advance\hsize-\wd0
14 | \advance\hsize-1em
15 | \obeylines
16 | \parindent=0pt
17 | \aftergroup\egroup
18 | \strut
19 | \let\dummy=}
20 |
21 | \def\enddefun{\hfil\defuntype\egroup\smallskip}
22 |
23 |
--------------------------------------------------------------------------------
/t2p-example/osdwcvs.t2p:
--------------------------------------------------------------------------------
1 | % .t2p file for main.texi (the GPLed portion of
2 | % *Open Source Development with CVS*, by Karl Fogel).
3 |
4 | % Create a main.t2p file alongside main.texi with
5 | % contents
6 | % \input osdwcvs.t2p
7 |
8 |
9 | \let\PRIMsection\section
10 |
11 | \input texinfo.t2p
12 |
13 | % main.texi doesn't number its chapters, although the
14 | % printed book seems to. Let's number them...
15 |
16 | \let\unnumbered\chapter
17 |
18 | % Let's start each section on a new HTML page
19 |
20 | \def\section#1
21 | {\eject\PRIMsection{#1}\label{#1}}
22 |
23 |
24 |
--------------------------------------------------------------------------------
/texample.tex:
--------------------------------------------------------------------------------
1 | %last modified 2016-11-17
2 | \input tex2page
3 | \input tgtermes
4 | \nopagenumbers
5 |
6 | The following listing is of the example \TeX\ file \p{story.tex},
7 | which should be available in your \TeX\ distribution. It is also
8 | listed on page 24 of D. E. Knuth’s {\sl The \TeX book}.
9 |
10 | You can of course use any example file you want. \p{story.tex}
11 | merely happens to be the “first” example file in the \TeX\
12 | collective consciousness. 74.3\% of all \TeX\ users learned
13 | \TeX\ by analyzing this file.
14 |
15 | \bigskip
16 |
17 | \verbatiminput story.tex
18 |
19 | \bye
20 |
--------------------------------------------------------------------------------
/slidecss.tex:
--------------------------------------------------------------------------------
1 | % last modified 2017-01-28
2 |
3 | \let\TZPslides=1
4 |
5 | % \incremental makes the rest of the enclosing group incremental
6 |
7 | \def\incremental{\ifx\shipout\UnDeFiNeD
8 | \rawhtml\endrawhtml
9 | \aftergroup\incrementalQclose\fi}
10 |
11 | \def\incrementalQclose{\rawhtml\endrawhtml}
12 |
13 | \let\maybeendinput\relax
14 | \ifx\shipout\UnDeFiNeD
15 | \else\let\maybeendinput\endinput
16 | \fi\maybeendinput
17 |
18 | \cssblock
19 | div.slide {
20 | margin-top: 3%;
21 | margin-left: 6%;
22 | margin-right: 6%;
23 | line-height: 2;
24 | }
25 |
26 | .slide h1,h2 {
27 | color: hsl(0,44%,42%); /* resene terracotta pink */
28 | border-bottom: 2px solid silver;
29 | }
30 |
31 | .slide h1.title {
32 | font-size: 240%;
33 | }
34 | \endcssblock
35 |
--------------------------------------------------------------------------------
/story.log:
--------------------------------------------------------------------------------
1 | This is LuaTeX, Version 1.0.4 (TeX Live 2017/Debian) (format=luatex 2018.5.10) 3 JUL 2018 07:38
2 | restricted system commands enabled.
3 | **story
4 | (/usr/share/texlive/texmf-dist/tex/plain/knuth-lib/story.tex [1{/var/lib/texmf/f
5 | onts/map/pdftex/updmap/pdftex.map}])
6 | *\end
7 |
10 | Output written on story.pdf (1 page, 35962 bytes).
11 |
12 | PDF statistics: 20 PDF objects out of 1000 (max. 8388607)
13 | 13 compressed objects within 1 object stream
14 | 0 named destinations out of 1000 (max. 131072)
15 | 1 words of extra memory for PDF output out of 10000 (max. 100000000)
16 |
17 |
--------------------------------------------------------------------------------
/t2p-example/chicken.t2p:
--------------------------------------------------------------------------------
1 | % .t2p file for manual.tex (the Chicken Scheme user
2 | % manual by Felix Winkelmann).
3 |
4 | % Create a manual.t2p file alongside manual.tex with
5 | % contents
6 | % \input chicken.t2p
7 |
8 |
9 | %\evalh{(set! *tex-format* 'latex)}
10 | \definitelylatex
11 |
12 | \htmlimageformat{png}
13 |
14 | \htmlmathstyle{no-in-text-image}
15 |
16 | %\externaltitle{CHICKEN -- A practical and portable Scheme
17 | %system -- User's manual (Version 0, Build 1082)}
18 |
19 | \let\sectionORIG\section
20 | \def\section{\vfill\eject\sectionORIG}
21 |
22 | \let\documentORIG\document
23 | \def\document{%
24 | \def\urlfootnote##1{\footnote{\url{##1}}}%
25 | \documentORIG}
26 |
27 | \imgpreamble
28 | \usepackage{graphics}
29 | \let\documentORIG\document
30 | \def\document{\documentORIG\LARGE}
31 | \endimgpreamble
32 |
33 |
--------------------------------------------------------------------------------
/ursa-major.tex:
--------------------------------------------------------------------------------
1 | \makehtmlimage{
2 | \newdimen\unit
3 | \def\point#1 #2 {\rlap{\kern#1\unit
4 | \raise#2\unit\hbox{$
5 | \scriptstyle\bullet\;(#1,#2)$}}}
6 | \unit=\baselineskip
7 | \centerline{\vtop{\hrule
8 | \hbox{\vrule height10\unit depth9.4\unit \kern2\unit
9 | \hbox{%
10 | \point 0 0 % Alioth (Epsilon Ursae Majoris), mag 1.79
11 | \point 0 8 % Dubhe (Alpha Ursae Majoris), mag 1.81
12 | \point 0 -8 % Alkaid (Eta Ursae Majoris), mag 1.87
13 | \point -1 -2.5 % Mizar (Zeta Ursae Majoris), mag 2.26
14 | \point 4 7 % Merak (Beta Ursae Majoris), mag 2.37
15 | \point 4 2 % Phekda (Gamma Ursae Majoris), mag 2.44
16 | \point 1 1.5 % Megrez (Delta Ursae Majoris), mag 3.30
17 | }% Src: Atlas of the Universe; Astronomy Data Book
18 | \kern7\unit \vrule}\hrule}}
19 | }
20 |
--------------------------------------------------------------------------------
/dialects/dialects-supported.scm:
--------------------------------------------------------------------------------
1 | ; last change 2023-01-02
2 | abcl ;v 1.9.0; WORKS!
3 | allegro ;v 9.0; WORKS!
4 | ; bigloo
5 | chez ;v 9.5.9; WORKS!
6 | chibi ;v 0.10.0
7 | chicken ;v 5.3.1; WORKS!
8 | ; clasp
9 | clisp ;v 2.49; WORKS!
10 | clozure ;v 1.12.1; WORKS!
11 | cmucl ;v 20d; WORKS!
12 | ; cyclone
13 | ecl ;v 21.2.1; WORKS!
14 | gambit ;v 4.9.3; WORKS!
15 | gauche ;v 0.9.10; WORKS!
16 | guile ;v 3.0.8; WORKS!
17 | ; ikarus
18 | ; kawa ;not much success, but no recent tries: stack seems to blow fairly easily
19 | ; larceny
20 | mitscheme ;v 11.2; WORKS!
21 | mkcl ;v 1.1.10; WORKS!
22 | petite ;v 9.5.9; WORKS!
23 | ; plt ;lib version for PLT: not quite yet
24 | ; pscheme
25 | racket ;v 8.6; WORKS!
26 | ; rscheme
27 | sbcl ;v 2.2.3; WORKS!
28 | sbcl-compiled ;v 2.2.3; WORKS!
29 | ; scheme48
30 | ; scm ;v 5f3
31 | ; scsh
32 | ; stk ;RIP?
33 | stklos ;v 1.70; WORKS!
34 | ; sxm
35 | ; umbscheme
36 | ; ypsilon ;does not work; token buffer overflows while reading string
37 |
--------------------------------------------------------------------------------
/dialects/stk-tex2page.rkt:
--------------------------------------------------------------------------------
1 | (scmxlate-cond
2 | ((eqv? *operating-system* 'unix)
3 | (scmxlate-insert
4 | "#!/bin/sh
5 | \":\";exec snow -file $0 -- $*
6 | ")))
7 |
8 | (define *scheme-version* "STk")
9 |
10 | (scmxlate-uncall
11 | require)
12 |
13 |
14 | (scmxlate-rename
15 | (flush-output flush)
16 | )
17 |
18 | (define get-arg1
19 | (lambda ()
20 | (and (pair? *argv*) (car *argv*))))
21 |
22 |
23 | (define delete-file
24 | (lambda (f) #t))
25 |
26 |
27 | (define file-or-directory-modify-seconds
28 | (lambda (f) #f))
29 |
30 | (define eof (call-with-input-string "" read))
31 |
32 | (define reverse!
33 | (lambda (s)
34 | (let loop ((s s) (r '()))
35 | (if (null? s) r
36 | (let ((d (cdr s)))
37 | (set-cdr! s r)
38 | (loop d s))))))
39 |
40 | (define ormap
41 | (lambda (f s)
42 | ;Returns true if f is true of some elt in s
43 | (let loop ((s s))
44 | (if (null? s) #f
45 | (or (f (car s)) (loop (cdr s)))))))
46 |
47 | (define seconds-to-human-time
48 | (lambda (secs) ""))
49 |
50 | ; ex:ft=scheme
51 |
--------------------------------------------------------------------------------
/dialects/plt-common-tex2page.scm:
--------------------------------------------------------------------------------
1 | ;last change: 2006-05-22
2 |
3 | (scmxlate-rename-define
4 | (eval1 eval))
5 |
6 | (scmxlate-uncall
7 | require
8 | trace
9 | )
10 |
11 | (scmxlate-cond
12 | ((<= *dialect-version* 299)
13 | (define string-upcase
14 | (lambda (s)
15 | (list->string
16 | (map char-upcase
17 | (string->list s)))))))
18 |
19 | (scmxlate-cond
20 | ((>= *dialect-version* 200)
21 |
22 | (scmxlate-ignore
23 | table)
24 |
25 | (scmxlate-rename-define
26 | (table-put! hash-table-put!)
27 | (table-for-each hash-table-for-each)
28 | )
29 |
30 | (define make-table
31 | (lambda z
32 | (if (null? z)
33 | (make-hash-table)
34 | (make-hash-table 'equal))))
35 |
36 | (define table-get
37 | (lambda (ht k . d)
38 | (hash-table-get ht k
39 | (let ((d (if (null? d) #f (car d))))
40 | (lambda () d)))))
41 | ))
42 |
43 | (scmxlate-rename-define
44 | (*january-number* 1)
45 | (*sunday-number* 0)
46 | (*anno-domini-at-0* 0)
47 | )
48 |
--------------------------------------------------------------------------------
/dialects/string-ports.scm:
--------------------------------------------------------------------------------
1 | ;string ports
2 |
3 | (define *output-strings* '())
4 |
5 | (define open-output-string
6 | (let ((n 0))
7 | (lambda ()
8 | (let ((f (string-append *jobname* "-Z-SC-"
9 | (number->string n) ".scm")))
10 | (set! n (+ n 1))
11 | (if (file-exists? f)
12 | ;try again
13 | (open-output-string)
14 | (let ((o (open-output-file f)))
15 | (set! *output-strings*
16 | (cons (cons o f) *output-strings*))
17 | o))))))
18 |
19 | (define get-output-string
20 | (lambda (o)
21 | (let ((o-f (assv o *output-strings*)))
22 | (let ((o (car o-f))
23 | (f (cdr o-f)))
24 | (close-output-port o)
25 | (let ((s (call-with-input-file f
26 | (lambda (o)
27 | (let loop ((r '()))
28 | (let ((c (read-char o)))
29 | (if (eof-object? c)
30 | (list->string (reverse! r))
31 | (loop (cons c r)))))))))
32 | (delete-file f)
33 | s)))))
34 |
35 |
36 |
--------------------------------------------------------------------------------
/texrc.tex:
--------------------------------------------------------------------------------
1 | % last modified 2018-07-02
2 | % Dorai Sitaram
3 |
4 | \input tgtermes
5 | \input tex2page.tex
6 | \input tex2pagerc
7 |
8 | %\font\tentt "Ubuntu Mono" at 10pt
9 | \font\tentt cmtt10
10 | \def\visiblespace{\relax\char`\ }
11 | %\font\eighttt "TeX Gyre Cursor:-liga:embolden=1" at 8pt
12 | \font\eighttt cmtt10 at 8pt
13 | \font\fourteenrm "TeX Gyre Termes" at 14pt
14 | %\font\fourteenrm "TeX Gyre Schola" at 14pt
15 | %\font\fourteenrm "Latin Modern Roman/B" at 14pt
16 | \font\twelvebf "TeX Gyre Heros/B" at 12pt
17 | \font\tensansbf "TeX Gyre Heros/B" at 10pt
18 |
19 | %\font\tenbf "Ubuntu/B" at 10pt
20 | %\font\tenbf "Ubuntu/M" at 10pt
21 | %\font\eighttt "Ubuntu Mono" at 8pt
22 | %\font\fourteenrm "Ubuntu" at 14pt
23 | %\font\twelvebf "Ubuntu/B" at 12pt
24 | %\font\tensansbf "Ubuntu/B" at 10pt
25 |
26 | \font\eightrm "TeX Gyre Termes" at 8pt
27 | \font\eightit "TeX Gyre Termes/I" at 8pt
28 |
29 | \def\titlefont{\fourteenrm \baselineskip=16.8pt \relax}
30 |
31 | \def\chapterfont{\twelvebf
32 | \baselineskip 14.4pt \relax}
33 |
34 | \def\sectionfont{\tensansbf}
35 |
36 | \def\eightfont{\eightrm
37 | \let\it\eightit
38 | \let\tt\eighttt
39 | \baselineskip 9.6pt \relax}
40 |
41 | \def\footnotehook{\eightfont}
42 |
--------------------------------------------------------------------------------
/t2p-example/btxdoc.t2p:
--------------------------------------------------------------------------------
1 | % btxdoc.t2p
2 | % Dorai Sitaram
3 | % Nov 11, 2000
4 |
5 | % last change 2006-05-31
6 |
7 | % This file contains the tex2page macros needed to process
8 | % the document btxdoc.tex ("BibTeXing", by Oren Patashnik).
9 | % Copy (or link) this file alongside btxdoc.tex and run
10 | %
11 | % tex2page btxdoc
12 |
13 | \let\TZPtexlayout=1
14 |
15 | \headline={\the\footline}
16 |
17 | \let\TZPtextmathimage 0
18 | \let\TZPdisplaymathimage 0
19 | %\htmlmathstyle{no-image}
20 | %\dontuseimgforhtmlmath
21 |
22 | %\let\kern\relax
23 |
24 | \def\TZPtitle{BibTeXing}
25 |
26 | % html uses a \simplerBibTeX than the more complicated
27 | % \BibTeX defined in btxdoc.tex
28 | \def\simplerBibTeX{B{\small IB}\TeX}
29 |
30 | \title{\simplerBibTeX ing}
31 |
32 | % ignore \title in btxdoc.tex
33 | \def\title#1{}
34 |
35 | % every section but the first starts a new page
36 |
37 | \let\ORIGsection\section
38 | \newcount\firstsection
39 | \firstsection=1
40 |
41 | \def\section{\ifnum\firstsection=1
42 | \global\firstsection=0
43 | \else\eject\fi
44 | \ORIGsection}
45 |
46 | \let\ORIGdocument\document
47 |
48 | \def\document{\ORIGdocument
49 | \let\BibTeX\simplerBibTeX
50 | }
51 |
--------------------------------------------------------------------------------
/dialects/fake-strftime.scm:
--------------------------------------------------------------------------------
1 | ;last change: 2003-06-02
2 |
3 | (define *short-month-names*
4 | (vector "Jan" "Feb" "March" "April" "May" "June"
5 | "July" "Aug" "Sept" "Oct" "Nov" "Dec"))
6 |
7 | (define *week-day-names*
8 | (vector "Sun" "Mon" "Tues" "Wed" "Thurs" "Fri" "Sat"))
9 |
10 | (define strftime-like
11 | (lambda (ignore-format d)
12 | (if (not d) ""
13 | (let ((h (date-hour d))
14 | (m (date-minute d)))
15 | (string-append
16 | (vector-ref *week-day-names*
17 | (modulo (- (date-week-day d)
18 | *sunday-number*) 7))
19 | ", "
20 | (vector-ref *short-month-names*
21 | (- (date-month d) *january-number*))
22 | " "
23 | (number->string (date-day d))
24 | ", "
25 | (number->string (+ *anno-domini-at-0* (date-year d)))
26 | ", "
27 | (number->string
28 | (let ((h (modulo h 12)))
29 | ;12h watch
30 | (if (= h 0) 12 h)))
31 | ":"
32 | (if (< m 10) "0" "")
33 | (number->string m)
34 | (if (<= 0 h 11) " am" " pm")
35 | ;incoming date is UTC, not localtime
36 | " UTC")))))
37 |
--------------------------------------------------------------------------------
/dialects/kawa-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change: 2016-12-14
2 |
3 | ;don't know how to make shell-magic line for
4 | ;Kawa, so we'll assume user will do explicit
5 | ;load
6 |
7 | (scmxlate-ignore
8 | ;get-arg1
9 | ;main
10 | )
11 |
12 | ;(scmxlate-uncall main)
13 |
14 | (define *scheme-version* "Kawa 1.6.99")
15 |
16 | (define *operating-system* 'unix)
17 |
18 | (define getenv (lambda (ev) #f))
19 |
20 | (scmxlate-uncall
21 | require
22 | )
23 |
24 | (define eof
25 | (call-with-input-string "" read))
26 |
27 | (define file-or-directory-modify-seconds
28 | (lambda (f) #f))
29 |
30 |
31 | (define ormap
32 | (lambda (f s)
33 | ;Returns true if f is true of some elt in s
34 | (let loop ((s s))
35 | (if (null? s) #f
36 | (or (f (car s)) (loop (cdr s)))))))
37 |
38 | (define append!
39 | (lambda (s1 s2)
40 | ;appends s1 and s2 destructively (s1 may be modified)
41 | (if (null? s1) s2
42 | (let loop ((r1 s1))
43 | (if (null? r1) (error 'append! s1 s2)
44 | (let ((r2 (cdr r1)))
45 | (if (null? r2)
46 | (begin
47 | (set-cdr! r1 s2)
48 | s1)
49 | (loop r2))))))))
50 |
51 | (define seconds-to-human-time
52 | (lambda (secs) ""))
53 |
54 | (define current-seconds
55 | (lambda ()
56 | #f))
57 |
58 |
59 |
--------------------------------------------------------------------------------
/tgtermes.tex:
--------------------------------------------------------------------------------
1 | % Dorai Sitaram
2 | % last change 2020-11-14
3 |
4 | \let\maybeendinput\relax
5 |
6 | \ifx\shipout\UnDeFiNeD
7 | % no need to load for TeX2page,
8 | % but allow Unicode chars directly
9 | \let\TZPtextext=0
10 | \let\maybeendinput\endinput
11 | \fi\maybeendinput
12 |
13 | \ifx\XeTeXversion\UnDeFiNeD
14 | \ifx\directlua\UnDeFiNeD
15 | % using neither XeTeX nor luaTeX
16 | \message{Use XeTeX or luaTeX!}%
17 | \let\maybeendinput\endinput
18 | \else
19 | % extra file needed for luaTeX
20 | \input luaotfload.sty
21 | \fi
22 | \fi\maybeendinput
23 |
24 | \let\oldtenrm\tenrm
25 |
26 | \font\tenrm "TeX Gyre Termes" at 10pt
27 |
28 | \ifx\tenrm\nullfont
29 | \let\tenrm\oldtenrm
30 | \message{Please install TeX Gyre fonts on your system!}%
31 | \let\maybeendinput\endinput
32 | \fi\maybeendinput
33 |
34 | \font\sevenrm "TeX Gyre Termes" at 7pt
35 | \font\fiverm "TeX Gyre Termes" at 5pt
36 |
37 | \font\tenbf "TeX Gyre Termes/B" at 10pt
38 | \font\sevenbf "TeX Gyre Termes/B" at 7pt
39 | \font\fivebf "TeX Gyre Termes/B" at 5pt
40 |
41 | \font\tentt "TeX Gyre Cursor:-liga;embolden=1" at 10pt
42 | %\font\tentt "Latin Modern Mono" at 10pt
43 |
44 | \font\tensl "TeX Gyre Termes:slant=0.2" at 10pt
45 |
46 | \font\tenit "TeX Gyre Termes/I" at 10pt
47 |
48 | \def\visiblespace{·}
49 | \def\_{\char"5F }
50 |
51 | \rm
52 |
--------------------------------------------------------------------------------
/2col.tex:
--------------------------------------------------------------------------------
1 | % last change 2016-11-20
2 | % from the TeXbook, p. 257
3 |
4 | \newdimen\fullhsize
5 | \fullhsize\hsize
6 |
7 | \def\fullline{\hbox to\fullhsize}
8 |
9 | \ifx\plainmakeheadline\undefined
10 | % ensure that we do this only once!
11 | \let\plainmakeheadline\makeheadline
12 | \let\plainmakefootline\makefootline
13 | \fi
14 |
15 | % the text width spans both columns, as far as
16 | % head- and footlines are concerned
17 |
18 | \def\textwideline{\hbox to\fullhsize}
19 |
20 | \def\makeheadline{{\let\line\textwideline\plainmakeheadline}}
21 | \def\makefootline{{\let\line\textwideline\plainmakefootline}}
22 |
23 | % space between the two columns — can be changed
24 | % immediately after loading 2col
25 |
26 | \def\gutter#1{\hsize\fullhsize
27 | \advance\hsize-#1
28 | \hsize.5\hsize
29 | }
30 |
31 | \gutter{1.5pc}
32 |
33 | \let\lr=L
34 |
35 | \newbox\leftcolumn
36 |
37 | \output={\if L\lr
38 | \global\setbox\leftcolumn=\columnbox
39 | \global\let\lr=R\else
40 | \doubleformat
41 | \global\let\lr L\fi
42 | \ifnum\outputpenalty>-20000 \else
43 | \dosupereject\fi}
44 |
45 | \def\doubleformat{\shipout\vbox{\makeheadline
46 | \fullline{\box\leftcolumn\hfil\columnbox}%
47 | \makefootline}\advancepageno}
48 |
49 | \def\columnbox{\leftline{\pagebody}}
50 |
51 | % \bye cleans up.
52 |
53 | \outer\def\bye{\vfill\supereject
54 | \if R\lr\null\vfill\eject\fi
55 | \end}
56 |
--------------------------------------------------------------------------------
/tex2pagerc.tex:
--------------------------------------------------------------------------------
1 | % last modified 2023-01-01
2 | % Dorai Sitaram
3 |
4 | \let\maybeendinput\relax
5 | \ifx\shipout\UnDeFiNeD\else
6 | \let\maybeendinput\endinput
7 | \fi
8 | \maybeendinput
9 |
10 | \def\TZPhsize{25em}
11 | \let\TZPautomargin=1
12 |
13 | \inputcss https://fonts.googleapis.com/css?family=Proza+Libre&display=swap
14 |
15 | \inputcss http://fonts.googleapis.com/css?family=Linden+Hill&display=swap
16 |
17 | % \inputcss https://fonts.googleapis.com/css?family=Miltonian&display=swap
18 |
19 | % \inputcss http://fonts.googleapis.com/css?family=Sorts+Mill+Goudy&display=swap
20 |
21 | % \inputcss http://fonts.googleapis.com/css?family=EB+Garamond&display=swap
22 |
23 | \cssblock
24 | .title,.chapter,.section {
25 | font-family: 'proza libre', sans-serif;
26 | }
27 |
28 | .title {
29 | color: hsl(0,0%,35%);
30 | /* color: hsl(0,44%,42%); /* resene terracotta pink */
31 | }
32 |
33 | .chapter {
34 | margin-top: 1.8em;
35 | font-size: 150%;
36 | }
37 |
38 | .section {
39 | margin-top: 1.5em;
40 | font-size: 110%;
41 | }
42 |
43 | a:hover {
44 | text-decoration: none;
45 | background-color: hsl(60,80%,74%);
46 | }
47 |
48 | .chapter a {
49 | text-decoration: none;
50 | }
51 |
52 | /*
53 | .item {
54 | font-family: 'miltonian', sans-serif;
55 | }
56 | */
57 |
58 | .oldstyle {
59 | font-family: 'linden hill', sans-serif;
60 | font-size: 110%;
61 | }
62 | \endcssblock
63 |
--------------------------------------------------------------------------------
/t2p-example/sicp-css.t2p:
--------------------------------------------------------------------------------
1 | % sicp-css.t2p
2 | % Dorai Sitaram
3 | % 19 Jan 2001
4 | % style information for SICP's HTML pages
5 |
6 | \cssblock
7 |
8 | body {
9 | color: black;
10 | /* background-color: #e5e5e5; */
11 | /* background-color: beige;*/
12 | background-color: white;
13 | margin-top: 2em;
14 | margin-left: 8%;
15 | margin-right: 8%;
16 | }
17 |
18 | h1,h2,h3,h4,h5,h6 {
19 | margin-top: .5em;
20 | }
21 |
22 | .partheading {
23 | font-size: 70%;
24 | }
25 |
26 | .chapterheading {
27 | font-size: 70%;
28 | }
29 |
30 | ol {
31 | list-style-type: decimal;
32 | }
33 |
34 | ol ol {
35 | list-style-type: lower-alpha;
36 | }
37 |
38 | ol ol ol {
39 | list-style-type: lower-roman;
40 | }
41 |
42 | ol ol ol ol {
43 | list-style-type: upper-alpha;
44 | }
45 |
46 | .footnote {
47 | font-size: 75%;
48 | }
49 |
50 | .epigraph {
51 | /* text-align: right; */
52 | font-size: 75%;
53 | }
54 |
55 | .figure {
56 | background-color: lavender;
57 | }
58 |
59 | .table {
60 | background-color: pink;
61 | }
62 |
63 | .navigation {
64 | color: red;
65 | text-align: right;
66 | font-style: italic;
67 | }
68 |
69 | .smallprint {
70 | color: gray;
71 | font-size: 75%;
72 | text-align: right;
73 | }
74 |
75 | .smallprint hr {
76 | text-align: left;
77 | width: 40%;
78 | }
79 |
80 | .disable {
81 | /* color: #e5e5e5; */
82 | color: gray;
83 | }
84 |
85 |
86 | \endcssblock
87 |
--------------------------------------------------------------------------------
/like-plt-logo.tex:
--------------------------------------------------------------------------------
1 | % lambda.mp
2 | % last modified 20161111
3 |
4 | \verbwritefile lambda.mp
5 | \verbwrite{
6 | % File: lambda.mp
7 |
8 | prologues := 3;
9 | outputformat := "eps";
10 | outputtemplate := "%j-%c.%o";
11 |
12 | beginfig(1);
13 | r = 2cm;
14 |
15 | path c; c = fullcircle scaled 2r;
16 |
17 | z.lambda.top = (0,(r-2mm)) rotated 15;
18 | z.lambda.lft = (0,-(r-2mm)) rotated -40;
19 | z.lambda.rt = (0,-(r-2mm)) rotated 40;
20 | z.pi = (0,r+3mm);
21 |
22 | path d; d = quartercircle scaled 2r rotated -90 &
23 | halfcircle scaled 2r;
24 |
25 | fill c withcolor red;
26 |
27 | z.lambda.mid = .5[z.lambda.top,z.lambda.rt];
28 |
29 | path lambda.top, lambda.rt;
30 | lambda.top = z.lambda.mid .. (0,(r+1mm)) rotated 15;
31 | lambda.rt = z.lambda.mid .. (0,-(r+1mm)) rotated 40;
32 |
33 | path bluepart; bluepart = buildcycle(lambda.top, d, lambda.rt);
34 |
35 | fill bluepart withcolor blue;
36 |
37 | drawdblarrow (-r,-(r+6mm)) -- (r, -(r+6mm));
38 | label.bot(btex $1$ etex, (0,-(r+7mm)));
39 |
40 | drawarrow z.pi rotated 8 .. z.pi rotated 80 ..
41 | z.pi rotated 178;
42 | drawarrow z.pi rotated -8 .. z.pi rotated -80 ..
43 | z.pi rotated -178;
44 | label(btex $\pi$ etex, z.pi);
45 |
46 | pickup pencircle scaled 4mm;
47 | draw z.lambda.top .. z.lambda.rt withcolor white;
48 | draw .4[z.lambda.top,z.lambda.rt] .. z.lambda.lft withcolor white;
49 |
50 | endfig;
51 | end.
52 | }
53 | \verbwritefile Z-eof
54 |
--------------------------------------------------------------------------------
/t2p-example/eplain.t2p:
--------------------------------------------------------------------------------
1 | % eplain.t2p
2 | % 7 Jan 2001
3 |
4 | % last change 2006-05-31
5 |
6 | \let\TZPtexlayout=1
7 |
8 | \headline={\the\footline}
9 |
10 | \input texi2p
11 |
12 | \imgpreamble
13 | \magnification1440
14 | \input eplain
15 | \endimgpreamble
16 |
17 | % \findex argument has tacit \ in front
18 |
19 | \def\findex#1
20 | {\index{#1@{\tt\TIIPbackslash#1}}}
21 |
22 |
23 | % kludges
24 |
25 | \let\PRIMleavevmode\leavevmode
26 | \let\PRIMkern\kern
27 |
28 | \def\kern{
29 | \let\NEXT\PRIMkern
30 | \ifnum\pageno=6
31 | \let\NEXT\comment
32 | \fi
33 | \NEXT}
34 |
35 | \def\leavevmode{
36 | \let\NEXT\PRIMleavevmode
37 | \ifnum\pageno=6
38 | $\hbox{\frac 23/{64}}$\let\NEXT\relax
39 | \fi
40 | \NEXT}
41 |
42 | \let\PRIMxref\xref
43 | \newcount\xrefnr
44 |
45 | \def\makeindexdoc#1{See the MakeIndex documentation}
46 |
47 | \def\xref{
48 | \let\NEXT\PRIMxref
49 | \ifnum\pageno=6
50 | \global\advance\xrefnr by 1
51 | \else
52 | \global\xrefnr=0
53 | \fi
54 | \ifnum\xrefnr=5
55 | \let\NEXT\makeindexdoc
56 | \else\ifnum\xrefnr=6
57 | \let\NEXT\makeindexdoc
58 | \fi\fi
59 | \NEXT}
60 |
61 | % \title has \TeX which doesn't show up well on external title
62 |
63 | \let\settitle\c
64 |
65 | \def\TZPtitle{Expanded Plain TeX}
66 |
67 | %\def\endtitlepage{\eject\noindent{\bf Contents}\medskip\tableofcontents}
68 |
69 | \def\unnumbered#1
70 | {\let\unnumbered\c
71 | \NONTEXINFOchapter*{Index}}
72 |
73 | %\let\printindexORIG\printindex
74 | %\def\printindex{\def\printindex#1#2{}
75 | %\printindexORIG}
76 |
77 | %\def\unnumbered#1
78 | %{}
79 |
--------------------------------------------------------------------------------
/dialects/racket-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ;last change: 2012-04-21
2 |
3 | (scmxlate-cond
4 | ((eqv? *operating-system* 'unix)
5 | (scmxlate-insert
6 | "#!/bin/sh
7 | \":\";exec racket -q -C $0 \"$@\"
8 | "))
9 |
10 | ((eqv? *operating-system* 'windows)
11 | (scmxlate-insert
12 | ";@echo off
13 | ;goto :start
14 | \":\";dosify=$(echo $0|sed -e 's,^//\\(.\\)/,\\1:/,')
15 | \":\";exec racket -r $dosify \"$@\"
16 | #|
17 | :start
18 | echo. > c:\\_temp.tmp
19 | echo (load (find-executable-path \"tex2page.bat\" >> c:\\_temp.tmp
20 | echo \"tex2page.bat\")) >> c:\\_temp.tmp
21 | racket -r c:\\_temp.tmp %1
22 | goto :eof
23 | |#
24 | ")))
25 |
26 | (scmxlate-include "plt-common-tex2page.scm")
27 |
28 | (scmxlate-postamble)
29 |
30 | (scmxlate-cond
31 | ((eqv? *operating-system* 'windows)
32 | (scmxlate-insert
33 | "
34 | ;:eof
35 | ")))
36 |
37 | (scmxlate-postprocess
38 | ; (call-with-output-file "t2p4plt.tex"
39 | ; (lambda (o)
40 | ; (fprintf o "%uncomment following to create ~
41 | ; plt-specific document~%~%~
42 | ; %\\let\\inpltdist t~%"))
43 | ; 'replace)
44 | (let ((it "t2p4plt.tex"))
45 | (when (file-exists? it)
46 | (delete-file it)))
47 | )
48 |
49 | (scmxlate-cond
50 | ((eqv? *operating-system* 'windows)
51 | (scmxlate-postprocess
52 | (call-with-output-file "tex2page.bat"
53 | (lambda (o)
54 | (fprintf o "@echo off ~%~
55 | d:\\plt\\racket -r d:\\public_html\\tex2page\\my-tex2page %1~%"))
56 | 'replace)
57 | )))
58 |
--------------------------------------------------------------------------------
/dialects/mitscheme-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ;last change: 2022-12-28
2 |
3 | (scmxlate-cond
4 | ((eqv? *operating-system* 'unix)
5 | (scmxlate-insert
6 | (string-append
7 | "\":\";"
8 | "exec mit-scheme "
9 | "--load $0 "
10 | "-- $1\n\n"
11 | ))))
12 |
13 | (declare (usual-integrations))
14 |
15 | (define *scheme-version*
16 | (string-append "MIT Scheme " (get-subsystem-version-string "release")))
17 |
18 | (scmxlate-uncall
19 | define-namespace-anchor
20 | require
21 | tex2page
22 | )
23 |
24 | (scmxlate-rename
25 | (date-day decoded-time/day)
26 | (date-hour decoded-time/hour)
27 | (date-minute decoded-time/minute)
28 | (date-month decoded-time/month)
29 | (date-year decoded-time/year)
30 | (seconds->date file-time->local-decoded-time)
31 | (list* cons*)
32 | (add1 1+)
33 | (sub1 -1+)
34 | (remove delete)
35 | )
36 |
37 | (scmxlate-ignoredef-rename
38 | (*tex2page-namespace* user-initial-environment)
39 | (seconds-to-human-time file-time->local-time-string)
40 | (string-index string-find-next-char)
41 | (string-reverse-index string-find-previous-char)
42 | (substring? string-search-forward)
43 | )
44 |
45 | (define (ormap f s)
46 | (there-exists? s f))
47 |
48 | (define (index-of s x)
49 | (let loop ((s s) (i 0))
50 | (cond ((null? s) false)
51 | ((eq? (car s) x) i)
52 | (else (loop (cdr s) (+ i 1))))))
53 |
54 | (define (current-seconds)
55 | (universal-time->file-time (get-universal-time)))
56 |
57 | (scmxlate-postamble)
58 |
59 | (let ((cla (command-line-arguments)))
60 | (when (> (length cla) 0)
61 | (tex2page (car cla))
62 | (exit 0)))
63 |
--------------------------------------------------------------------------------
/dialects/mzscheme-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ;last change: 2005-03-30
2 |
3 | (scmxlate-cond
4 | ((eqv? *operating-system* 'unix)
5 | (scmxlate-insert
6 | "#!/bin/sh
7 | \":\";exec mzscheme -q -C $0 \"$@\"
8 | "))
9 |
10 | ((eqv? *operating-system* 'windows)
11 | (scmxlate-insert
12 | ";@echo off
13 | ;goto :start
14 | \":\";dosify=$(echo $0|sed -e 's,^//\\(.\\)/,\\1:/,')
15 | \":\";exec mzscheme -r $dosify \"$@\"
16 | #|
17 | :start
18 | echo. > c:\\_temp.tmp
19 | echo (load (find-executable-path \"tex2page.bat\" >> c:\\_temp.tmp
20 | echo \"tex2page.bat\")) >> c:\\_temp.tmp
21 | mzscheme -r c:\\_temp.tmp %1
22 | goto :eof
23 | |#
24 | ")))
25 |
26 |
27 | ;(scmxlate-cond
28 | ;((>= *dialect-version* 200)
29 | ; ;MzScheme version 200 and above have pushed
30 | ; ;system into a lib that must be explicitly
31 | ; ;loaded
32 | ; (require (lib "process.ss"))
33 | ; ))
34 | ;
35 | (scmxlate-include "plt-common-tex2page.scm")
36 |
37 | (scmxlate-postamble)
38 |
39 | (scmxlate-cond
40 | ((eqv? *operating-system* 'windows)
41 | (scmxlate-insert
42 | "
43 | ;:eof
44 | ")))
45 |
46 | (scmxlate-postprocess
47 | ; (call-with-output-file "t2p4plt.tex"
48 | ; (lambda (o)
49 | ; (fprintf o "%uncomment following to create ~
50 | ; plt-specific document~%~%~
51 | ; %\\let\\inpltdist t~%"))
52 | ; 'replace)
53 | (let ((it "t2p4plt.tex"))
54 | (when (file-exists? it)
55 | (delete-file it)))
56 | )
57 |
58 | (scmxlate-cond
59 | ((eqv? *operating-system* 'windows)
60 | (scmxlate-postprocess
61 | (call-with-output-file "tex2page.bat"
62 | (lambda (o)
63 | (fprintf o "@echo off ~%~
64 | d:\\plt\\mzscheme -r d:\\public_html\\tex2page\\my-tex2page %1~%"))
65 | 'replace)
66 | )))
67 |
68 |
--------------------------------------------------------------------------------
/t2p-example/scshdoc.tex:
--------------------------------------------------------------------------------
1 | \def\sv{0.6.2}
2 |
3 |
4 | \title{Online versions of the Scsh documentation}
5 |
6 | \subsubsection*{The documents}
7 |
8 | \nocite{scsh-paper,scsh-man}
9 |
10 | \bibliographystyle{plain}
11 | \bibliography{../tex2page}
12 |
13 | \subsubsection*{Generating them}
14 |
15 | \enumerate
16 | \item Get and unpack
17 | \urlh{http://www.scsh.net}{Scsh}.
18 | This will create a directory \p{scsh-|sv}
19 | (modulo version number).
20 |
21 | \item Get and install
22 | \urlh{../tex2page-doc.html}{TeX2page}. This will create a
23 | directory \p{tex2page}.
24 |
25 | (TeX2page is known to install on Scsh on Unix.
26 | However, for the least installation hassle,
27 | consider
28 | running TeX2page on
29 | \urlh{http://www.plt-scheme.org/software/mzscheme}{MzScheme}.
30 | TeX2page runs ``out of the box'' on MzScheme on any
31 | operating system.)
32 |
33 | \item Put a copy or link of
34 | \p{tex2page/t2p-example/scsh-paper.t2p} in
35 | \p{scsh-|sv/doc/scsh-paper}. Alternatively, ensure that
36 | \p{scsh-paper.t2p} is in one of the directories
37 | mentioned in the environment variable
38 | \p{TIIPINPUTS}. (The \p{TIIPINPUTS} value looks like
39 | the \p{PATH} value, ie, it is a list of directories,
40 | colon-separated in Unix and semicolon-separated in
41 | Windows.)
42 |
43 | \item Put a copy or link of \p{tex2page/t2p-example/man.t2p}
44 | in \p{scsh-|sv/doc/scsh-manual}. Alternatively,
45 | ensure that \p{man.t2p} is in \p{TIIPINPUTS}.
46 |
47 | \item In each of the directories \p{scsh-|sv/doc}
48 | and \p{scsh-|sv/doc/scsh-manual}, create a file \p{.tex2page.hdir}
49 | that contains the word \p{html}. This tells TeX2page to
50 | create the HTML files in a subdirectory \p{html}. (This
51 | step is optional, but helps to avoid cluttering
52 | the source directory.)
53 |
54 | \item Cd to \p{scsh-|sv/doc/scsh-paper} and run \p{tex2page scsh-paper}.
55 | (Do it twice to resolve cross-references.)
56 |
57 | \item Cd to \p{scsh-|sv/doc/scsh-manual} and run \p{tex2page man}.
58 | (Do it twice.)
59 |
60 | \item Browse \p{scsh-|sv/doc/scsh-paper/html/scsh-paper.html} and
61 | \p{scsh-|sv/doc/scsh-manual/html/man.html} using your
62 | favorite HTML browser.
63 | \endenumerate
64 |
65 | \bye
66 |
--------------------------------------------------------------------------------
/dialects/sxm-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change: 2016-12-14
2 |
3 | (scmxlate-cond
4 | ((eqv? *operating-system* 'unix)
5 | (scmxlate-insert
6 | "\":\";echo '"
7 | "(define arg-one \"'$1'\")"
8 | "(load \"'$0'\")"
9 | "(main (list 1 arg-one))"
10 | "(exit)"
11 | "'|exec sxi; exit"
12 | "
13 |
14 | "))
15 |
16 | )
17 |
18 |
19 |
20 |
21 | (define *scheme-version* "SXM")
22 |
23 | (scmxlate-ignore
24 | with-output-to-port)
25 |
26 | (scmxlate-uncall
27 | require
28 | trace
29 | )
30 |
31 | ;(define get-arg1
32 | ; (lambda ()
33 | ; (and (top-level-bound? 'arg-one) arg-one)))
34 |
35 | (define eof (call-with-input-string "" read))
36 |
37 | (define flush-output
38 | (lambda z
39 | #f))
40 |
41 | ;sxm issues warnings for forward-references,
42 | ;which can't all be removed anyway
43 |
44 | (warning-handler (lambda zzz #f))
45 |
46 | (define trace-if
47 | (lambda (write? . args)
48 | #t ;noop! But w/o this, sxm fails
49 | (when write?
50 | (write-log #\newline)
51 | (when *current-tex-line-number*
52 | (write-log "l.")
53 | (write-log *current-tex-line-number*)
54 | (write-log #\space))
55 | (for-each write-log args)
56 | (write-log #\newline))))
57 |
58 |
59 |
60 | (scmxlate-cond
61 | ((eqv? *operating-system* 'unix)
62 | (define file-or-directory-modify-seconds
63 | (lambda (f)
64 | (let* ((x (process
65 | (string-append "stat -c \"%Y\" " f)))
66 | (n (read (car x))))
67 | (close-input-port (car x))
68 | (close-output-port (cadr x))
69 | n))))
70 | (else
71 | (define file-or-directory-modify-seconds
72 | (lambda (f) #f))))
73 |
74 | ;(define file-or-directory-modify-seconds
75 | ; (lambda (f) #f))
76 |
77 | (define read-line
78 | (lambda (i)
79 | (let ((c (peek-char i)))
80 | (if (eof-object? c) c
81 | (let loop ((r '()))
82 | (let ((c (read-char i)))
83 | (if (or (eof-object? c) (char=? c #\newline))
84 | (list->string (reverse! r))
85 | (loop (cons c r)))))))))
86 |
87 | ;(define seconds-to-human-time
88 | ; (lambda (secs)
89 | ; ""))
90 |
91 | (scmxlate-include "seconds-to-date.scm")
92 |
--------------------------------------------------------------------------------
/dialects/guile-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change: 2022-12-28
2 |
3 | (scmxlate-cond
4 | ((eqv? *operating-system* 'unix)
5 | (scmxlate-insert
6 | "#!/bin/sh\n"
7 | "exec guile -e main -s $0 \"$@\"\n"
8 | "!#\n\n"
9 | )))
10 |
11 | (define *scheme-version*
12 | (string-append "Guile " (version)))
13 |
14 | (define *tex2page-namespace* (interaction-environment))
15 |
16 | (scmxlate-ignore
17 | call-with-input-string
18 | get-time-zone
19 | get-arg1
20 | string-index
21 | with-output-to-port)
22 |
23 | (scmxlate-rename
24 | (date-day tm:mday)
25 | (date-hour tm:hour)
26 | (date-minute tm:min)
27 | (date-month tm:mon)
28 | (date-year tm:year)
29 | (seconds->date localtime)
30 | )
31 |
32 | (scmxlate-rename-define
33 | ; (*return* #\return)
34 | ; (*tab* #\tab)
35 | (string-reverse-index string-rindex)
36 | (*january-number* 0)
37 | (*anno-domini-at-0* 1900)
38 | (strftime-like strftime)
39 | )
40 |
41 | (scmxlate-uncall
42 | require
43 | )
44 |
45 | (define-macro unless
46 | (lambda (b . ee)
47 | `(if (not ,b) (begin ,@ee))))
48 |
49 | (define-macro when
50 | (lambda (b . ee)
51 | `(if ,b (begin ,@ee))))
52 |
53 | (define-macro fluid-let
54 | (lambda (xvxv . ee)
55 | (let ((xx (map car xvxv))
56 | (vv (map cadr xvxv))
57 | (old-xx (map (lambda (xv)
58 | (string->symbol
59 | (string-append "%__"
60 | (symbol->string (car xv))))) xvxv))
61 | (res '%_*_res))
62 | `(let ,(map (lambda (old-x x) `(,old-x ,x)) old-xx xx)
63 | ,@(map (lambda (x v)
64 | `(set! ,x ,v)) xx vv)
65 | (let ((,res (begin ,@ee)))
66 | ,@(map (lambda (x old-x) `(set! ,x ,old-x)) xx old-xx)
67 | ,res)))))
68 |
69 | (define file-or-directory-modify-seconds
70 | (lambda (f) (vector-ref (stat f) 9)))
71 |
72 | (define read-line
73 | (lambda (i)
74 | (let ((c (peek-char i)))
75 | (if (eof-object? c) c
76 | (let loop ((r '()))
77 | (let ((c (read-char i)))
78 | (if (or (eof-object? c) (char=? c #\newline))
79 | (list->string (reverse! r))
80 | (loop (cons c r)))))))))
81 |
82 | (define main
83 | (lambda (args)
84 | (tex2page
85 | (and (>= (length args) 2)
86 | (list-ref args 1)))))
87 |
--------------------------------------------------------------------------------
/dialects/pscheme-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ;no command-line arg. Just load and call tex2page proc
2 | (define get-arg1
3 | (lambda ()
4 | #f))
5 |
6 | (define *scheme-version*
7 | (string-append "Pocket Scheme "
8 | (let ((v (map number->string (version))))
9 | (string-append
10 | (list-ref v 0) "."
11 | (list-ref v 1) "."
12 | (list-ref v 2) "."
13 | (list-ref v 3)))))
14 |
15 | (scmxlate-uncall
16 | require
17 | )
18 |
19 | (define getenv
20 | (lambda (env-var)
21 | #f))
22 |
23 | (define ormap
24 | (lambda (f s)
25 | ;Returns true if f is true of some elt in s
26 | (let loop ((s s))
27 | (if (null? s) #f
28 | (or (f (car s)) (loop (cdr s)))))))
29 |
30 | (define andmap
31 | (lambda (f s)
32 | (let loop ((s s))
33 | (if (null? s) #t
34 | (and (f (car s)) (loop (cdr s)))))))
35 |
36 | (define eof
37 | (let* ((i (open-input-string ""))
38 | (eof (read i)))
39 | (close-input-port i)
40 | eof))
41 |
42 | (define-macro unless
43 | (lambda (b . ee)
44 | `(if (not ,b) (begin ,@ee))))
45 |
46 | (define-macro when
47 | (lambda (b . ee)
48 | `(if ,b (begin ,@ee))))
49 |
50 | (define-macro fluid-let
51 | (lambda (xvxv . ee)
52 | (let ((xx (map car xvxv))
53 | (vv (map cadr xvxv))
54 | (old-xx (map (lambda (xv)
55 | (string->symbol
56 | (string-append "%__"
57 | (symbol->string (car xv))))) xvxv))
58 | (res '%_*_res))
59 | `(let ,(map (lambda (old-x x) `(,old-x ,x)) old-xx xx)
60 | ,@(map (lambda (x v)
61 | `(set! ,x ,v)) xx vv)
62 | (let ((,res (begin ,@ee)))
63 | ,@(map (lambda (x old-x) `(set! ,x ,old-x)) xx old-xx)
64 | ,res)))))
65 |
66 | (define file-or-directory-modify-seconds
67 | (lambda (f)
68 | #f))
69 |
70 | (define decode-seconds-since-epoch
71 | (lambda (secs)
72 | #f))
73 |
74 | (define current-seconds
75 | (lambda ()
76 | #f))
77 |
78 | (define file-exists?
79 | (lambda (f)
80 | (member f (directory-list "."))))
81 |
82 | (define flush-output force-output)
83 |
84 | ;(define)
85 |
86 | ; ex:ft=scheme
87 |
--------------------------------------------------------------------------------
/dialects/plt-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change: 2009-04-09
2 |
3 | (scmxlate-insert
4 | ";tex2page
5 | ;(c) Dorai Sitaram, 1997-2002
6 |
7 | (module tex2page-aux mzscheme
8 | (require mzlib/process)
9 | (require mzlib/date)
10 | (require scheme/private/more-scheme)
11 | ;(require (lib \"process.ss\"))
12 | ;(require (lib \"date.ss\"))
13 | (provide (all-defined-except ))
14 |
15 | ")
16 |
17 | (scmxlate-uncall
18 | require)
19 |
20 | (scmxlate-ignore
21 | ;get-arg1
22 | main
23 | )
24 |
25 | (scmxlate-rename
26 | ;(tex2page tex2page-aux)
27 | )
28 |
29 | (scmxlate-include "plt-common-tex2page.scm")
30 |
31 | (scmxlate-postamble)
32 |
33 | (scmxlate-insert
34 | (string-append
35 | ")"
36 | "
37 | "))
38 |
39 | (scmxlate-postprocess
40 |
41 | (define save-file
42 | (lambda (f1 f2 . replace?)
43 | (let ((replace? (and (pair? replace?) (car replace?))))
44 | (when (and (file-exists? f2) replace?)
45 | (delete-file f2))
46 | (when (and (file-exists? f1)
47 | (not (file-exists? f2)))
48 | (copy-file f1 f2)))))
49 |
50 | ;(save-file "t2p4plt.tex" "t2p4plt.tex.orig")
51 |
52 | ; (call-with-output-file "t2p4plt.tex"
53 | ; (lambda (o)
54 | ; (fprintf o "% Delete this file for ~
55 | ; non-PLT-specific document~%~%~
56 | ; \\let\\inpltdist t~%"))
57 | ; 'replace)
58 |
59 | (printf "Generated files are tex2page.ss and tex2page-aux.ss.~%~
60 | Put them in PLTHOME/collects/tex2page.~%")
61 |
62 | (save-file "my-tex2page" "tex2page-aux.ss" #t)
63 |
64 | (call-with-output-file "tex2page.ss"
65 | (lambda (o)
66 | (pretty-print
67 | `(module tex2page mzscheme
68 | ;(require (lib "etc.ss"))
69 | (require mzlib/etc)
70 | (provide tex2page)
71 | ;
72 | (define tex2page
73 | (lambda (f)
74 | (parameterize ((current-namespace (make-namespace)))
75 | (namespace-require `(file
76 | ,(path->string
77 | (build-path (this-expression-source-directory)
78 | "tex2page-aux.ss"))))
79 | ((namespace-variable-value 'tex2page) f)))))
80 | o))
81 | #:exists
82 | 'replace)
83 | )
84 |
85 |
--------------------------------------------------------------------------------
/dialects/stklos-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ;last change: 2023-01-01
2 |
3 | (scmxlate-cond
4 | ((eqv? *operating-system* 'unix)
5 | (scmxlate-insert
6 | "#!/usr/bin/env stklos-script\n")))
7 |
8 | (define *scheme-version*
9 | (string-append "STklos " (version)))
10 |
11 | (scmxlate-ignoredef
12 | table
13 | )
14 |
15 | (scmxlate-uncall
16 | define-namespace-anchor
17 | require
18 | tex2page)
19 |
20 | (scmxlate-rename
21 | (ormap any)
22 | (remove delete)
23 | (substring subseq)
24 | )
25 |
26 | (define *tex2page-namespace* (interaction-environment))
27 |
28 | (define (make-table . z)
29 | (if (null? z)
30 | (make-hash-table)
31 | (make-hash-table (cadr z))))
32 |
33 | (define (table-get k ht . d)
34 | (hash-table-ref ht k
35 | (lambda ()
36 | (if (null? d) #f (car d)))))
37 |
38 | (define (table-put! k tbl v)
39 | (hash-table-set! tbl k v))
40 |
41 | (define (table-for-each p tbl)
42 | (hash-table-for-each tbl p))
43 |
44 | (define (add1 n) (+ n 1))
45 |
46 | (define (sub1 n) (- n 1))
47 |
48 | (define (string-trim s)
49 | (let ((orig-n (string-length s)))
50 | (let ((i 0) (n orig-n))
51 | (let loop ((k i))
52 | (cond ((>= k n) (set! i n))
53 | ((char-whitespace? (string-ref s k))
54 | (loop (+ k 1)))
55 | (else (set! i k))))
56 | (let loop ((k (- n 1)))
57 | (cond ((<= k i) (set! n (+ k 1)))
58 | ((char-whitespace? (string-ref s k))
59 | (loop (- k 1)))
60 | (else (set! n (+ k 1)))))
61 | (if (and (= i 0) (= n orig-n)) s
62 | (substring s i n)))))
63 |
64 | (define (subseq s i . z)
65 | (let ((f (if (pair? z) (car z) (string-length s))))
66 | (substring s i f)))
67 |
68 | (define (index-of s x)
69 | (let loop ((s s) (i 0))
70 | (cond ((null? s) false)
71 | ((eq? (car s) x) i)
72 | (else (loop (cdr s) (+ i 1))))))
73 |
74 | (define (string=split s sep)
75 | (string-split s (string sep)))
76 |
77 | (define (file-or-directory-modify-seconds f)
78 | (let-values ([(tmpf o) (create-temp-file)])
79 | (close-port o)
80 | (system (string-append "stat -c %W " f " > " tmpf))
81 | (let ([n (call-with-input-file tmpf read)])
82 | (delete-file tmpf)
83 | n)))
84 |
85 | (define (date-time-zone-offset d)
86 | ;STklos's date-tz's result is opposite in sign to Racket's date-time-zone-offset's
87 | (- (date-tz d)))
88 |
89 | (scmxlate-postamble)
90 |
91 | (let ((cla (argv)))
92 | (tex2page (and (> (length cla) 0) (car cla))))
93 |
--------------------------------------------------------------------------------
/dialects/scm-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change: 2003-06-21
2 |
3 | (scmxlate-cond
4 | ((eqv? *operating-system* 'unix)
5 | (scmxlate-insert
6 | "\":\";exec scm -l $0 \"$@\"
7 | ")))
8 |
9 | (define *scheme-version*
10 | (string-append "SCM " (symbol->string *scm-version*)))
11 |
12 | (scmxlate-rename
13 | (andmap every)
14 | (append! nconc)
15 | (flush-output force-output)
16 | (gensym gentemp)
17 | (ormap some)
18 | )
19 |
20 | (scmxlate-ignore
21 | call-with-input-string
22 | with-output-to-port)
23 |
24 | (scmxlate-uncall
25 | require)
26 |
27 |
28 | (require 'line-i/o)
29 | (require 'common-list-functions)
30 |
31 |
32 | ;(define get-arg1
33 | ; (lambda ()
34 | ; (let ((pa (program-arguments)))
35 | ; (and (> (length pa) 3)
36 | ; (list-ref pa 3)))))
37 |
38 |
39 | (defmacro unless (b . ee)
40 | `(if (not ,b) (begin ,@ee)))
41 |
42 | (defmacro when (b . ee)
43 | `(if ,b (begin ,@ee)))
44 |
45 | (define eof
46 | (call-with-input-string "" read))
47 |
48 |
49 | (scmxlate-cond
50 | ((not (defined? 'reverse!))
51 | (define reverse!
52 | (lambda (s)
53 | (let loop ((s s) (r '()))
54 | (if (null? s) r
55 | (let ((d (cdr s)))
56 | (set-cdr! s r)
57 | (loop d s))))))))
58 |
59 |
60 | ;string ports
61 |
62 | (define *output-strings* '())
63 |
64 | (define open-output-string
65 | (lambda ()
66 | (let* ((f (tmpnam))
67 | (o (open-output-file f)))
68 | (set! *output-strings*
69 | (cons (cons o f) *output-strings*))
70 | o)))
71 |
72 | (define get-output-string
73 | (lambda (o)
74 | (let ((o-f (assv o *output-strings*)))
75 | (let ((o (car o-f))
76 | (f (cdr o-f)))
77 | (close-output-port o)
78 | (let ((s (call-with-input-file f
79 | (lambda (o)
80 | (let loop ((r '()))
81 | (let ((c (read-char o)))
82 | (if (eof-object? c)
83 | (list->string (reverse! r))
84 | (loop (cons c r)))))))))
85 | (delete-file f)
86 | s)))))
87 |
88 | ;(define kall-with-input-string call-with-input-string)
89 |
90 | (scmxlate-cond
91 | ((defined? stat)
92 | (define file-or-directory-modify-seconds
93 | (lambda (f)
94 | (vector-ref (stat f) 9))))
95 | (else
96 | (define file-or-directory-modify-seconds
97 | (lambda (f) 0))))
98 |
99 | (define andmap every)
100 |
101 | (scmxlate-include "seconds-to-date.scm")
102 |
103 | (scmxlate-postamble)
104 |
105 | (let ((pa (program-arguments)))
106 | (and (> (length pa) 3)
107 | (tex2page (list-ref pa 3))))
108 |
--------------------------------------------------------------------------------
/coloraug.tex:
--------------------------------------------------------------------------------
1 | % Last modified 2018-06-28
2 | % Dorai Sitaram
3 |
4 | \let\maybeendinput\relax
5 | \ifx\shipout\UnDeFiNeD
6 | \let\maybeendinput\endinput
7 | \else\edef\fmtnameQplain{plain}%
8 | \ifx\fmtname\fmtnameQplain\else
9 | \let\maybeendinput\endinput
10 | \fi
11 | \fi\maybeendinput
12 |
13 | % Load color.sty, which defines rgb, cmyk, gray.
14 | % It also defines hsb, but not for LuaTeX.
15 |
16 | \ifx\definecolor\UnDeFiNeD
17 | \ifx\miniltx\UnDeFiNeD
18 | \input miniltx
19 | \fi
20 | \input color.sty
21 | \fi
22 |
23 | \let\colorQorig\color
24 |
25 | \let\definecolorQorig\definecolor
26 |
27 | \def\color{\futurelet\colorQi\colorQii}
28 |
29 | \def\colorQii{\ifx\colorQi[\let\colorQiii\colorQwithmodel
30 | \else\let\colorQiii\colorQorig\fi\colorQiii}
31 |
32 | \let\maybeendinput\relax
33 | \ifx\directlua\UnDeFiNeD
34 | \input colorxe
35 | \let\maybeendinput\endinput
36 | \fi\maybeendinput
37 |
38 | \directlua{require(kpse.find_file('colormodels.lua'))}
39 |
40 | \def\colorQwithmodel[#1]{\directlua{
41 | local model = '#1'
42 | if model == 'HTML' then
43 | tex.print("\noexpand\\colorQwithmodelnondecimal[" .. model .. "]")
44 | else
45 | tex.print("\noexpand\\colorQwithmodeldecimal[" .. model .. "]")
46 | end
47 | }}
48 |
49 | \def\colorQwithmodeldecimal[#1]#2{\directlua{
50 | local model = "#1"
51 | local values = { #2 }
52 | local newmodel, newvalues = convert_to_known_color_model(model, values)
53 | tex.print("\noexpand\\colorQorig[" .. newmodel .. "]" .. convert_to_csv(newvalues))
54 | }}
55 |
56 | \def\colorQwithmodelnondecimal[#1]#2{\directlua{
57 | local model = "#1"
58 | local values = { 0x#2 }
59 | local newmodel, newvalues = convert_to_known_color_model(model, values)
60 | tex.print("\noexpand\\colorQorig[" .. newmodel .. "]" .. convert_to_csv(newvalues))
61 | }}
62 |
63 | \def\definecolor#1#2{\directlua{
64 | local name = '#1'
65 | local model = '#2'
66 | if model == 'HTML' then
67 | tex.print("\noexpand\\definecolorQnondecimal{" .. name .. "}{" .. model .. "}")
68 | else
69 | tex.print("\noexpand\\definecolorQdecimal{" .. name .. "}{" .. model .. "}")
70 | end
71 | }}
72 |
73 | \def\definecolorQdecimal#1#2#3{\directlua{
74 | local name = '#1'
75 | local model = '#2'
76 | local values = { #3 }
77 | local newmodel, newvalues = convert_to_known_color_model(model, values)
78 | tex.print("\noexpand\\definecolorQorig{" .. name .. "}{" .. newmodel .. "}" ..
79 | convert_to_csv(newvalues))
80 | }}
81 |
82 | \def\definecolorQnondecimal#1#2#3{\directlua{
83 | local name = '#1'
84 | local model = '#2'
85 | local values = { 0x#3 }
86 | local newmodel, newvalues = convert_to_known_color_model(model, values)
87 | tex.print("\noexpand\\definecolorQorig{" .. name .. "}{" .. newmodel .. "}" ..
88 | convert_to_csv(newvalues))
89 | }}
90 |
--------------------------------------------------------------------------------
/eval4tex.tex:
--------------------------------------------------------------------------------
1 | % eval4tex.tex
2 | % Dorai Sitaram
3 | % Last change 2017-01-16
4 |
5 | \let\maybeendinput\relax
6 | \ifx\shipout\UnDeFiNeD
7 | \let\maybeendinput\endinput
8 | \fi
9 | \maybeendinput
10 |
11 | \newcount\evalQauxfilecount
12 | \evalQauxfilecount=0
13 |
14 | {\catcode`\^^M=12 %
15 | \gdef\evalfortexQsetup{%
16 | \expandafter\csname newwrite\endcsname \evalfortexQport %
17 | %
18 | \immediate\openout\evalfortexQport \jobname-Z-E-D.lisp %
19 | \newlinechar=`\^^M%
20 | \immediate\write\evalfortexQport{
21 | (defmacro define (lhs &rest body)
22 | (if (consp lhs) `(defun ,(car lhs) ,(cdr lhs) ,@body)
23 | `(defvar ,lhs ,@body)))
24 |
25 | (defun current-output-port (&optional p)
26 | (if p (setq *standard-output* p) *standard-output*))
27 |
28 | (defun file-exists? (f) (probe-file f))
29 |
30 | (defun open-output-file (f)
31 | (open f :direction :output :if-exists :supersede))
32 |
33 | (defun close-output-port (p) (close p))
34 |
35 | (defun display (x) (princ x))
36 |
37 | (defun newline () (terpri))
38 |
39 | (defun integer->char (n) (code-char n))
40 | }%
41 | \immediate\closeout\evalfortexQport %
42 | %
43 | \immediate\openout\evalfortexQport \jobname-Z-E.lisp %
44 | %\newlinechar=`\^^M%
45 | \immediate\write\evalfortexQport{
46 | (if (not 'nil)
47 | (eval '(load "\jobname-Z-E-D.lisp"))
48 | (not 0))
49 |
50 | (define *eval4tex-current-output-port* (current-output-port))
51 |
52 | (define (eval4tex-preamble f)
53 | (if (file-exists? f) (delete-file f) 0)
54 | (current-output-port (open-output-file f)))
55 |
56 | (define (eval4tex-postamble)
57 | (display (integer->char 92))
58 | (display "relax") (newline)
59 | (close-output-port (current-output-port))
60 | (current-output-port *eval4tex-current-output-port*))
61 | }%
62 | \newlinechar=-1 %
63 | }%
64 | }
65 |
66 | \def\eval{\evalQi d} %display the output
67 | \def\evalq{\evalQi q} %don't display the output
68 |
69 | \def\evalQi#1{\begingroup
70 | \ifx\evalfortexQport\UNDEFINED \evalfortexQsetup\fi
71 | \global\advance\evalQauxfilecount by 1
72 | \edef\evalQauxfile{\jobname-Z-E-\the\evalQauxfilecount}%
73 | \immediate\write\evalfortexQport
74 | {(eval4tex-preamble "\evalQauxfile.tex")}%
75 | % should the following \input be in a group?
76 | \ifx#1d{\immediate\openin0=\evalQauxfile.tex
77 | \ifeof0 \immediate\closein0
78 | \else \immediate\closein0 \input \evalQauxfile.tex \fi}\fi
79 | \def\do##1{\catcode`##1=12 }\dospecials
80 | \catcode`\{=1 \catcode`\}=2
81 | \catcode`\|=0
82 | \catcode`\^^M=12
83 | \newlinechar=`\^^M%
84 | \evalQii}
85 |
86 | \def\evalQii#1{%
87 | \immediate\write\evalfortexQport{#1}%
88 | \immediate\write\evalfortexQport{(eval4tex-postamble)}%
89 | \newlinechar=-1 %
90 | \endgroup}
91 |
92 | % end of file
93 |
--------------------------------------------------------------------------------
/colormodels.lua:
--------------------------------------------------------------------------------
1 | -- Last modified 2018-06-28
2 | -- Dorai Sitaram
3 |
4 | local function hsl360_to_rgb(H, s, L)
5 | local c = (1 - math.abs(2*L - 1)) * s
6 | local x = c * (1 - math.abs(((H/60) % 2) - 1))
7 | local m = L - c/2
8 | local r1, g1, b1 = 0, 0, 0
9 | if H < 60 then r1 = c; g1 = x
10 | elseif H < 120 then r1 = x; g1 = c
11 | elseif H < 180 then g1 = c; b1 = x
12 | elseif H < 240 then g1 = x; b1 = c
13 | elseif H < 300 then r1 = x; b1 = c
14 | else r1 = c; b1 = x
15 | end
16 | return "rgb", { r1+m, g1+m, b1+m }
17 | end
18 |
19 | local function hsl_to_rgb(h, s, L)
20 | return hsl360_to_rgb(h * 360, s, L)
21 | end
22 |
23 | local function hsb360_to_rgb(h, s, b)
24 | local L = .5 * b * (2 - s)
25 | local s2 = (b * s) / (1 - math.abs(2*L - 1))
26 | return hsl360_to_rgb(h, s2, L)
27 | end
28 |
29 | local function hsb_to_rgb(h, s, b)
30 | return hsb360_to_rgb(h*360, s, b)
31 | end
32 |
33 | local function hsb240_to_rgb(h, s, b)
34 | return hsb_to_rgb(h/240, s/240, b/240)
35 | end
36 |
37 | local function cmy_to_rgb(c, m, y)
38 | return "rgb", { 1-c, 1-m, 1-y }
39 | end
40 |
41 | local function html_to_rgb(xn)
42 | local y = xn
43 | local r = math.floor(y / 0x10000)
44 | y = y % 0x10000
45 | local g = math.floor(y / 0x100)
46 | local b = y % 0x100
47 | return "rgb", { r/255, g/255, b/255 }
48 | end
49 |
50 | local function gray15_to_gray(g)
51 | return "gray", { g/15 }
52 | end
53 |
54 | local function wavelength_to_rgb(w)
55 | local h
56 | if w <= 362.857 then h = 5
57 | elseif w < 440 then h = 4 + (w - 440)/-60
58 | elseif w < 490 then h = 4 - (w - 440)/50
59 | elseif w < 510 then h = 2 + (w - 510)/-20
60 | elseif w < 580 then h = 2 - (w - 510)/70
61 | elseif w < 645 then h = (w - 645)/-65
62 | else h = 0
63 | end
64 | h = h * 1/6
65 | local b = 0
66 | if w <= 362.857 then b = 0
67 | elseif w < 420 then b = .3 + .7 * (w - 380)/40
68 | elseif w <= 700 then b = 1
69 | elseif w < 814.285 then b = .3 + .7 * (w - 780)/-80
70 | else b = 0
71 | end
72 | return hsb360_to_rgb(h*360, 1, b)
73 | end
74 |
75 | function convert_to_known_color_model(model, a)
76 | if model == 'hsb' then
77 | return hsb_to_rgb(a[1], a[2], a[3])
78 | elseif model == 'Hsb' then
79 | return hsb360_to_rgb(a[1], a[2], a[3])
80 | elseif model == 'HSB' then
81 | return hsb240_to_rgb(a[1], a[2], a[3])
82 | elseif model == 'hsl' then
83 | return hsl_to_rgb(a[1], a[2], a[3])
84 | elseif model == 'Hsl' then
85 | return hsl360_to_rgb(a[1], a[2], a[3])
86 | elseif model == 'cmy' then
87 | return cmy_to_rgb(a[1], a[2], a[3])
88 | elseif model == 'HTML' then
89 | return html_to_rgb(a[1])
90 | elseif model == 'Gray' then
91 | return gray15_to_gray(a[1])
92 | elseif model == 'wave' then
93 | return wavelength_to_rgb(a[1])
94 | else
95 | return model, a
96 | end
97 | end
98 |
99 | function convert_to_csv(a)
100 | local s = '{'
101 | for i = 1, #a do
102 | if i > 1 then
103 | s = s .. ', '
104 | end
105 | s = s .. string.format("%.4f", a[i])
106 | end
107 | s = s .. '}'
108 | return s
109 | end
110 |
--------------------------------------------------------------------------------
/dialects/chez-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change: 2022-12-28
2 |
3 | (scmxlate-eval
4 | (define *chez-name*
5 | (if (eqv? *dialect* 'petite)
6 | "petite"
7 | "scheme" ;or "chez"?
8 | )))
9 |
10 | (scmxlate-cond
11 |
12 | ((eqv? *operating-system* 'unix)
13 | (scmxlate-insert
14 | "#! /usr/local/bin/"
15 | *chez-name*
16 | " --script\n\n"
17 | ))
18 |
19 | ((eqv? *operating-system* 'windows)
20 | (scmxlate-insert
21 | "\":\";dosify=$(echo $0|sed -e 's,^//\\(.\\)/,\\1:/,')
22 | \":\";echo \"(define arg-one \\\"$1\\\")(load \\\"$dosify\\\")(exit)\"|exec "
23 | *chez-name*
24 | ";exit\n"))
25 | )
26 |
27 | (define *scheme-version* (scheme-version))
28 |
29 | (scmxlate-uncall
30 | define-namespace-anchor
31 | require
32 | tex2page
33 | )
34 |
35 | (scmxlate-rename
36 | (error chez-error)
37 | (get-char t2p-get-char)
38 | (substring subseq)
39 | (date-time-zone-offset date-zone-offset)
40 | )
41 |
42 | (scmxlate-ignoredef-rename
43 | (ensure-file-deleted delete-file)
44 | )
45 |
46 | (define *tex2page-namespace* (interaction-environment))
47 |
48 | (define (chez-error . args)
49 | (apply error #f args))
50 |
51 | (define (read-line i)
52 | (let ((c (peek-char i)))
53 | (if (eof-object? c) c
54 | (let loop ((r '()))
55 | (let ((c (read-char i)))
56 | (if (or (eof-object? c) (char=? c #\newline))
57 | (list->string (reverse! r))
58 | (loop (cons c r))))))))
59 |
60 | ;(scmxlate-include "seconds-to-date.scm")
61 |
62 | (define (call-with-input-string s p)
63 | (let* ((i (open-input-string s))
64 | (v (p i)))
65 | (close-input-port i)
66 | v))
67 |
68 | (define (index-of s x)
69 | (let loop ((s s) (i 0))
70 | (cond ((null? s) false)
71 | ((eq? (car s) x) i)
72 | (else (loop (cdr s) (+ i 1))))))
73 |
74 | (define (subseq s i . z)
75 | (let ((f (if (pair? z) (car z) (string-length s))))
76 | (substring s i f)))
77 |
78 | (define (current-seconds)
79 | (time-second (current-time)))
80 |
81 | (define (file-or-directory-modify-seconds f)
82 | (time-second (file-modification-time f)))
83 |
84 | (define (seconds->date s)
85 | (time-utc->date (make-time 'time-utc 0 s)))
86 |
87 | (scmxlate-cond
88 | ((eqv? *operating-system* 'windows)
89 | (define *ghostscript* "d:\\aladdin\\gs6.0\\bin\\gswin32c")
90 | ))
91 |
92 | (define (string-trim s)
93 | (let ((orig-n (string-length s)))
94 | (let ((i 0) (n orig-n))
95 | (let loop ((k i))
96 | (cond ((>= k n) (set! i n))
97 | ((char-whitespace? (string-ref s k))
98 | (loop (+ k 1)))
99 | (else (set! i k))))
100 | (let loop ((k (- n 1)))
101 | (cond ((<= k i) (set! n (+ k 1)))
102 | ((char-whitespace? (string-ref s k))
103 | (loop (- k 1)))
104 | (else (set! n (+ k 1)))))
105 | (if (and (= i 0) (= n orig-n)) s
106 | (substring s i n)))))
107 |
108 | (scmxlate-postamble)
109 |
110 | (let ((cla (command-line-arguments)))
111 | (tex2page
112 | (and (>= (length cla) 1) (car cla))))
113 |
--------------------------------------------------------------------------------
/dialects/gauche-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change: 2022-12-28
2 |
3 | (scmxlate-cond
4 | ((eqv? *operating-system* 'unix)
5 | (scmxlate-insert
6 | "\":\";exec gosh -- $0 \"$@\"\n")))
7 |
8 | (define *scheme-version*
9 | (string-append "Gauche " (gauche-version)))
10 |
11 | (scmxlate-ignoredef
12 | with-output-to-port
13 | call-with-input-string
14 | )
15 |
16 | (scmxlate-uncall
17 | define-namespace-anchor
18 | require
19 | tex2page
20 | )
21 |
22 | (scmxlate-rename
23 | (load disable-load-for-tex2page)
24 | (remove delete)
25 | (seconds->date sys-localtime)
26 | (substring subseq)
27 | )
28 |
29 | (scmxlate-ignoredef-rename
30 | (strftime sys-strftime)
31 | )
32 |
33 | (define *tex2page-namespace* (interaction-environment))
34 |
35 | (define (add1 n) (+ n 1))
36 | (define (sub1 n) (- n 1))
37 |
38 | (define (string-trim s)
39 | (let ((orig-n (string-length s)))
40 | (let ((i 0) (n orig-n))
41 | (let loop ((k i))
42 | (cond ((>= k n) (set! i n))
43 | ((char-whitespace? (string-ref s k))
44 | (loop (+ k 1)))
45 | (else (set! i k))))
46 | (let loop ((k (- n 1)))
47 | (cond ((<= k i) (set! n (+ k 1)))
48 | ((char-whitespace? (string-ref s k))
49 | (loop (- k 1)))
50 | (else (set! n (+ k 1)))))
51 | (if (and (= i 0) (= n orig-n)) s
52 | (substring s i n)))))
53 |
54 | (define (disable-load-for-tex2page f) #f)
55 |
56 | (define (file-or-directory-modify-seconds f)
57 | (sys-stat->mtime (sys-stat f)))
58 |
59 | (define (date-day tm) (slot-ref tm 'mday))
60 | (define (date-hour tm) (slot-ref tm 'hour))
61 | (define (date-minute tm) (slot-ref tm 'min))
62 | (define (date-month tm) (slot-ref tm 'mon))
63 | (define (date-year tm) (slot-ref tm 'year))
64 | (define (date-week-day tm) (slot-ref tm 'wday))
65 | (define (date-dst? tm) (slot-ref tm 'isdst))
66 | (define (date-time-zone-offset tm) #f)
67 |
68 | (define (string-upcase s)
69 | (list->string (map char-upcase (string->list s))))
70 |
71 | (define (index-of s x)
72 | (let loop ((s s) (i 0))
73 | (cond ((null? s) false)
74 | ((eq? (car s) x) i)
75 | (else (loop (cdr s) (+ i 1))))))
76 |
77 | (define (subseq s i . z)
78 | (let ((f (if (pair? z) (car z) (string-length s))))
79 | (substring s i f)))
80 |
81 | (define (ormap f s)
82 | ;Returns true if f is true of some elt in s
83 | (let loop ((s s))
84 | (if (null? s) #f
85 | (or (f (car s)) (loop (cdr s))))))
86 |
87 | (define-macro (fluid-let xvxv . ee)
88 | (let ((xx (map car xvxv))
89 | (vv (map cadr xvxv))
90 | (old-xx (map (lambda (xv)
91 | (string->symbol
92 | (string-append "%__"
93 | (symbol->string (car xv))))) xvxv))
94 | (res '%_*_res))
95 | `(let ,(map (lambda (old-x x) `(,old-x ,x)) old-xx xx)
96 | ,@(map (lambda (x v)
97 | `(set! ,x ,v)) xx vv)
98 | (let ((,res (begin ,@ee)))
99 | ,@(map (lambda (x old-x) `(set! ,x ,old-x)) xx old-xx)
100 | ,res))))
101 |
102 | (define (main args)
103 | (tex2page
104 | (and (>= (length args) 2)
105 | (list-ref args 1))))
106 |
--------------------------------------------------------------------------------
/t2p-example/man.t2p:
--------------------------------------------------------------------------------
1 | % man.t2p
2 | % Dorai Sitaram
3 | % Feb 6, 2000
4 |
5 | % This file contains the tex2page macros needed to process
6 | % the scsh LaTeX document scsh-n.n.n/doc/scsh-manual/man.tex.
7 | % Copy (or link) this file alongside man.tex and run
8 | %
9 | % tex2page man
10 |
11 | \htmlmathstyle{no-image}
12 |
13 | \let\pagebreak\relax
14 |
15 | \let\small\relax
16 |
17 | %\let\PRIMtableofcontents\tableofcontents
18 | %\def\tableofcontents{\chapter*{Contents}\PRIMtableofcontents}
19 |
20 | \def\subtitle#1{\def\savesubtitle{#1}}
21 |
22 | \def\maketitle{
23 | \subject{\TIIPtitle}
24 | {\bf \hr}
25 | \rightline{\savesubtitle}
26 | \bigskip\bigskip
27 | \bigskip\bigskip
28 | {\bf\TIIPauthor}
29 | {\bf\hr}
30 | }
31 |
32 | \let\PRIMdocument\document
33 |
34 | \def\document{\PRIMdocument
35 |
36 | \let\ttchars\relax
37 | \let\ttt\tt
38 |
39 | \def\~{\char`\~}
40 |
41 |
42 | % ~ should be verbatim inside \cd
43 | % (RT Happe, bug 508925 on SF)
44 |
45 | \def\cd#1{{\tt\def\\{\char`\\}\defcsactive\${\char`\$}%
46 | \defcsactive\~{\char`\~}\defcsactive\&{\char`\&}#1}}
47 |
48 |
49 | \def\cddollar{\undefcsactive\$}
50 | \def\cdmath{\undefcsactive\$}
51 | \def\codeallowbreaks{\relax}
52 | \def\defvarx#1#2{\index{#1}\leftline{{\tt #1} \qquad #2}}
53 |
54 | \let\PRIMflushright\flushright
55 |
56 | \def\flushright{\PRIMflushright\TIIPtabularborder=0 }
57 |
58 | \let\PRIMfigure\figure
59 | \let\PRIMendfigure\endfigure
60 |
61 | \def\figure{\par\hrule\PRIMfigure}
62 | \def\endfigure{\PRIMendfigure\hrule\par}
63 |
64 | \let\PRIMtable\table
65 | \let\PRIMendtable\endtable
66 |
67 | \def\table{\par\hrule\PRIMtable}
68 | \def\endtable{\PRIMendtable\hrule\par}
69 |
70 | \imgdef\vdots{\bf.\par.\par.}
71 |
72 | \def\spaceifnotempty#1{%
73 | \def\TEMP{#1}%
74 | \ifx\TEMP\empty\else\ \fi}
75 |
76 | % put \index ahead of the definition, so clicking on
77 | % the index entry points just above the definition --
78 | % suggested by Markus Holmberg
79 |
80 | \def\dfnix#1#2#3#4#5{\index{#5}\leftline{{\tt(#1\spaceifnotempty{#2}{\it#2})} \quad $\longrightarrow$ \quad {\it #3} \qquad (#4)}}
81 |
82 | %\def\ex#1{{\tt #1}}
83 | %\let\ex\texttt
84 | \def\l#1{lambda (#1)}
85 | \def\lx#1{lambda {#1}}
86 | %\def\notenum#1{}
87 | %\def\project#1{}
88 | %\def\var#1{{\it #1\/}}
89 | %\let\var\textit
90 | %\def\vari#1#2{\mbox{{\it #1\/}\undefcsactive\$$_{#2}$}}
91 | %\def\vari#1#2{\textit{#1}$_{#2}$}
92 |
93 | \renewenvironment{boxedfigure}{\def\srecomment#1{\\#1\\}%
94 | \begin{figure}\pagestyle}{\end{figure}}
95 |
96 | \newenvironment{centercode}{\begin{code}}{\end{code}}
97 |
98 | \def\setupcode{\tt%
99 | \def\\{\char`\\}%
100 | \defcsactive\${\$}%
101 | \def\evalto{==> }%
102 | \defcsactive\%{\%}\obeywhitespace}
103 |
104 | \newenvironment{code}{\begin{quote}\setupcode\GOBBLEOPTARG}
105 | {\end{quote}}
106 |
107 | \newenvironment{codebox}{\begin{tableplain}\bgroup\setupcode\GOBBLEOPTARG}
108 | {\egroup\end{tableplain}}
109 |
110 | \renewenvironment{desc}{\begin{quote}}{\end{quote}}
111 |
112 | \renewenvironment{exampletable}{%
113 | \def\header#1{\\\leftline{#1}\\}%
114 | \def\splitline#1#2{\\\leftline{#1}\\\leftline{#2}}%
115 | \begin{tabular}{}}{\end{tabular}}
116 |
117 | \newenvironment{tightcode}{\begin{code}}{\end{code}}
118 | \renewenvironment{widecode}{\begin{code}}{\end{code}}
119 |
120 | \renewenvironment{inset}{\begin{quote}}{\end{quote}}
121 | \renewenvironment{leftinset}{\begin{quote}}{\end{quote}}
122 | \renewenvironment{tightinset}{\begin{quote}}{\end{quote}}
123 | \renewenvironment{tightleftinset}{\begin{quote}}{\end{quote}}
124 | }
125 |
--------------------------------------------------------------------------------
/dialects/gambit-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change: 2022-12-29
2 |
3 | (scmxlate-cond
4 | ((eqv? *operating-system* 'unix)
5 | (scmxlate-insert
6 | "#! /usr/bin/env gsi\n\n")))
7 |
8 | (define *scheme-version*
9 | (string-append "Gambit " (system-version-string)))
10 |
11 | (define gambit-getenv
12 | (lambda (ev)
13 | (with-exception-handler (lambda (ex) #f)
14 | (lambda () (getenv ev)))))
15 |
16 | (scmxlate-uncall
17 | define-namespace-anchor
18 | require
19 | tex2page
20 | )
21 |
22 | (scmxlate-rename
23 | (getenv gambit-getenv)
24 | (substring subseq)
25 | )
26 |
27 | (define *tex2page-namespace* (interaction-environment))
28 |
29 | (define (subseq s i . z)
30 | (let ((f (if (pair? z) (car z) (string-length s))))
31 | (substring s i f)))
32 |
33 | (define index-of
34 | (lambda (s x)
35 | (let loop ((s s) (i 0))
36 | (cond ((null? s) false)
37 | ((eq? (car s) x) i)
38 | (else (loop (cdr s) (+ i 1)))))))
39 |
40 | (define (remove y xx)
41 | (let loop ((xx xx) (r '()))
42 | (if (null? xx) (reverse! r)
43 | (let ((x (car xx)))
44 | (loop (cdr xx)
45 | (if (equal? x y) r
46 | (cons x r)))))))
47 |
48 | (define (string-upcase s)
49 | (list->string (map char-upcase (string->list s))))
50 |
51 | (define current-seconds
52 | (lambda ()
53 | (inexact->exact (floor (time->seconds (current-time))))))
54 |
55 | (define-macro fluid-let
56 | (lambda (xvxv . ee)
57 | (let ((xx (map car xvxv))
58 | (vv (map cadr xvxv))
59 | (old-xx (map (lambda (xv)
60 | (string->symbol
61 | (string-append "%__"
62 | (symbol->string (car xv))))) xvxv))
63 | (res '%_*_res))
64 | `(let ,(map (lambda (old-x x) `(,old-x ,x)) old-xx xx)
65 | ,@(map (lambda (x v)
66 | `(set! ,x ,v)) xx vv)
67 | (let ((,res (begin ,@ee)))
68 | ,@(map (lambda (x old-x) `(set! ,x ,old-x)) xx old-xx)
69 | ,res)))))
70 |
71 | (define ormap
72 | (lambda (f s)
73 | ;Returns true if f is true of some elt in s
74 | (let loop ((s s))
75 | (if (null? s) #f
76 | (or (f (car s)) (loop (cdr s)))))))
77 |
78 | (define (append! l1 l2)
79 | (cond ((null? l1) l2)
80 | ((null? l2) l1)
81 | (else (let loop ((r1 l1))
82 | (let ((cdr-r1 (cdr r1)))
83 | (cond ((null? cdr-r1) (set-cdr! r1 l2) l1)
84 | (else (loop cdr-r1))))))))
85 |
86 | (define (add1 n) (+ n 1))
87 | (define (sub1 n) (- n 1))
88 |
89 | (define (string-trim s)
90 | (let ((orig-n (string-length s)))
91 | (let ((i 0) (n orig-n))
92 | (let loop ((k i))
93 | (cond ((>= k n) (set! i n))
94 | ((char-whitespace? (string-ref s k))
95 | (loop (+ k 1)))
96 | (else (set! i k))))
97 | (let loop ((k (- n 1)))
98 | (cond ((<= k i) (set! n (+ k 1)))
99 | ((char-whitespace? (string-ref s k))
100 | (loop (- k 1)))
101 | (else (set! n (+ k 1)))))
102 | (if (and (= i 0) (= n orig-n)) s
103 | (substring s i n)))))
104 |
105 | (define file-or-directory-modify-seconds
106 | (lambda (f)
107 | (inexact->exact
108 | (floor (time->seconds
109 | (file-info-last-modification-time (file-info f)))))))
110 |
111 | (scmxlate-include "seconds-to-date.scm")
112 |
113 | (define (main arg1 . ignore)
114 | (tex2page arg1))
115 |
116 | (scmxlate-postamble)
117 |
--------------------------------------------------------------------------------
/dialects/seconds-to-date.scm:
--------------------------------------------------------------------------------
1 | ;last change: 2022-12-26
2 | ;created < 2003-05-31
3 |
4 | (define *days-in-a-mo*
5 | (vector 31 28 31 30 31 30
6 | 31 31 30 31 30 31))
7 |
8 | (define *anno-domini-at-epoch* 1970) ;epoch is Jan 1, 1970
9 | (define *epoch-week-day* 4) ;it was a Thursday
10 |
11 | (define leap?
12 | (lambda (y)
13 | (or (and (= (modulo y 4) 0)
14 | (> (modulo y 100) 0))
15 | (= (modulo y 400) 0))))
16 |
17 | (define seconds->date
18 | ;decode-seconds-since-epoch
19 | (lambda (s . tz)
20 | (if (pair? tz) (set! s (- s (* 3600 (car tz)))))
21 | (let* (
22 | ;the day, counting from the epoch
23 | (d (quotient s 86400))
24 | ;the day of the week
25 | (dow (modulo (+ d *epoch-week-day*) 7))
26 | (s (- s (* d 86400)))
27 | ;the hour
28 | (h (quotient s 3600))
29 | (s (remainder s 3600))
30 | ;the minute
31 | (min (quotient s 60))
32 | ;the seconds after that minute
33 | (s (remainder s 60))
34 | )
35 |
36 | ;locate year by adding or subtracting a year's days from d,
37 | ;depending on which side of the epoch d is
38 |
39 | (let loop ((d d) (y *anno-domini-at-epoch*))
40 | (if (< d 0)
41 | ;try previous year
42 | (let ((y-1 (- y 1)))
43 | (loop (+ d (if (leap? y-1) 366 365)) y-1))
44 | (let* ((l? (leap? y))
45 | (d2 (if l? 366 365)))
46 | (if (>= d d2)
47 | ;try next year
48 | (loop (- d d2) (+ y 1))
49 |
50 | ;we're in the right year. now let's find which month
51 | ;we're in, by counting the number of subtractions needed
52 | ;to be within some month's days
53 | (let loop ((d d) (mo 0))
54 | (let ((d2 (vector-ref *days-in-a-mo* mo)))
55 | ;leap Februaries have one more day
56 | (if (and (= mo 1) l?) (set! d2 (+ d2 1)))
57 | (if (> d d2)
58 | ;try next month
59 | (loop (- d d2) (+ mo 1))
60 | ;we're in the right month. the days
61 | ;not subtracted give day-of-month.
62 | ;but we want days to be 1-based, not 0-based,
63 | ;so add 1. Years are
64 | ;1900-based, so subtract
65 | ;1900.
66 | (vector s
67 | min
68 | h
69 | (+ d 1)
70 | mo
71 | (- y 1900)
72 | dow)))))))))))
73 |
74 | (define date-second (lambda (v) (vector-ref v 0)))
75 | (define date-minute (lambda (v) (vector-ref v 1)))
76 | (define date-hour (lambda (v) (vector-ref v 2)))
77 | (define date-day (lambda (v) (vector-ref v 3)))
78 | (define date-month (lambda (v) (vector-ref v 4)))
79 | (define date-year (lambda (v) (vector-ref v 5)))
80 | (define date-week-day (lambda (v) (vector-ref v 6)))
81 |
82 | ;The time struct returned follows POSIX convention.
83 | ;In particular, January is 0, Sunday is 0, and the
84 | ;years are those since 1900 C.E.
85 |
86 | ;For comparison, PLT Scheme and Common Lisp have
87 | ;January = 1 and give years since 0 C.E. CL Lisp
88 | ;further has Monday = 0. Alone among Schemes, MIT
89 | ;Scheme follows CL. Schemes other than PLT and
90 | ;MIT follow POSIX.
91 |
92 | (define *january-number* 0)
93 | (define *sunday-number* 0)
94 | (define *anno-domini-at-0* 1900)
95 |
96 | (scmxlate-include "fake-strftime.scm")
97 |
98 | (scmxlate-ignoredef-rename
99 | (strftime strftime-like))
100 |
--------------------------------------------------------------------------------
/t2p-example/scsh-paper.t2p:
--------------------------------------------------------------------------------
1 | % scsh-paper.t2p
2 | % Dorai Sitaram
3 | % Feb 6, 2000
4 |
5 | % This file contains the tex2page macros needed to process
6 | % the scsh LaTeX document scsh-n.n.n/doc/scsh-paper.tex.
7 | % Copy (or link) this file alongside scsh-paper.tex and run
8 | % tex2page scsh-paper
9 |
10 | \htmlmathstyle{no-image}
11 |
12 | \let\clearpage\relax
13 | \let\cleardoublepage\relax
14 | \let\pagebreak\relax
15 |
16 | \let\PRIMsection\section
17 |
18 | \let\subsectionORIG\subsection
19 | \let\subsubsectionORIG\subsubsection
20 |
21 | %\let\PRIMtableofcontents\tableofcontents
22 | %\def\tableofcontents{\section*{Contents}\PRIMtableofcontents}
23 |
24 | \def\notenum#1{\def\savenotenum{#1}}
25 | \def\project#1{\def\saveproject{#1}}
26 | %\let\PRIMtitle\title
27 | %\def\title#1{\PRIMtitle{#1}\def\savetitle{#1}}
28 | %\def\author#1{\def\saveauthor{#1}}
29 | %\def\date#1{\def\savedate{#1}}
30 |
31 | \def\maketitle{
32 | \leftline{\sc massachusetts institute of technology}
33 | \smallskip
34 | %\centerline{Laboratory for Computer Science}
35 | %note: ~ is needed in the \makehtmlimage arg because the aux tex file should
36 | %contain something other than a \special for it to
37 | %produce anything
38 | \leftline{\makehtmlimage{\special{psfile=mitlogo.ps}~}\
39 | Laboratory for Computer Science}
40 | \smallskip
41 | \leftline{\saveproject\ Note \savenotenum\ \qquad \TIIPdate}
42 | \hr
43 | \subject{\TIIPtitle}
44 | \smallskip
45 | {\def\\{\egroup\break\bgroup}
46 | \centerline{\bf\TIIPauthor}}
47 | %\smallskip
48 | %\bigskip
49 | %\bigskip
50 | }
51 |
52 | \let\PRIMfigure\figure
53 | \let\PRIMendfigure\endfigure
54 |
55 | \def\figure{\par\hrule\PRIMfigure}
56 | \def\endfigure{\PRIMendfigure\hrule\par}
57 |
58 | \let\PRIMdocument\document
59 |
60 | \def\document{\PRIMdocument
61 |
62 | %\def\headingquote##1##2{
63 | %%\eject
64 | %\TIIPendgraf
65 | %\rawhtml
66 | %\endrawhtml
67 | %##1
68 | %\rawhtml \endrawhtml
69 | %~~~~~~---##2
70 | %\TIIPendgraf
71 | %\rawhtml |
\endrawhtml}
72 |
73 | \def\headingquote##1##2{{
74 | \obeylines\raggedleft\let\\\relax{\it ##1}
75 | ---##2}}
76 |
77 | %\def\section{\def\section{\vfill\eject\PRIMsection}%
78 | %\PRIMsection}
79 |
80 | \newcount\firstsectionp
81 | \firstsectionp=1
82 |
83 | \def\section{\ifnum\firstsectionp=1
84 | \global\firstsectionp=0
85 | \else\vfill\eject\fi
86 | \PRIMsection}
87 |
88 |
89 |
90 |
91 | %headings.tex redefines \[sub]*section, which
92 | %emit unwanted output, pointed out by Martin
93 | %Gasbichler. Let's therefore restore original
94 | %definitions for these commands.
95 |
96 | \let\subsection\subsectionORIG
97 | \let\subsubsection\subsubsectionORIG
98 |
99 | %\let\ttchars\relax
100 | \let\ttt\tt
101 | \def\cd##1{{\tt\def\\{\char`\\}\defcsactive\${\char`\$}%
102 | \defcsactive\&{\char`\&}##1}}
103 | \def\cddollar{\undefcsactive\$}
104 | %\def\ex#1{{\tt #1}}
105 | \def\l##1{lambda (##1)}
106 | \def\lx##1{lambda {##1}}
107 | %\def\var#1{{\it #1\/}}
108 | \def\vari##1##2{\mbox{\undefcsactive\$${\it
109 | ##1}_{##2}$}}
110 | %\def\vari#1#2{\mbox{{\it #1\/}\undefcsactive\$$_{#2}$}}
111 |
112 | %\renewcommand{\proto}[3]{{\tt(#1 {\it #2})} \qquad (#3)}
113 | \def\proto##1##2##3{{\tt(##1 {\it ##2})} \qquad (##3)}
114 |
115 | \def\setupcode{\tt%
116 | \def\\{\char`\\}%
117 | \defcsactive\${\$}%
118 | \def\evalto{==> }%
119 | \defcsactive\%{\%}\obeywhitespace}
120 |
121 | \newenvironment{code}{\begin{quote}\bgroup\setupcode\GOBBLEOPTARG}
122 | {\egroup\end{quote}}
123 |
124 | \newenvironment{codebox}{\begin{tableplain}\bgroup\setupcode\GOBBLEOPTARG}
125 | {\egroup\end{tableplain}}
126 |
127 | \newenvironment{tightcode}{\begin{code}}{\end{code}}
128 |
129 | \renewenvironment{inset}{\begin{quote}}{\end{quote}}
130 | \renewenvironment{leftinset}{\begin{quote}}{\end{quote}}
131 | \renewenvironment{tightinset}{\begin{quote}}{\end{quote}}
132 | \newenvironment{tightleftinset}{\begin{quote}}{\end{quote}}
133 |
134 | \renewenvironment{column}{\end{center}\bgroup\let\\\break}
135 | {\egroup\begin{center}}
136 | }
137 |
--------------------------------------------------------------------------------
/dialects/chicken-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change: 2022-12-28
2 |
3 | (scmxlate-insert
4 | (string-append
5 | "#!/usr/local/bin/csi -ss\n\n"))
6 |
7 | (import
8 | (chicken file)
9 | (chicken file posix)
10 | (chicken io)
11 | (chicken platform)
12 | (chicken port)
13 | (chicken pretty-print)
14 | (chicken process)
15 | (chicken process-context)
16 | (chicken time)
17 | (chicken time posix)
18 | )
19 |
20 | (define *scheme-version*
21 | (string-append "Chicken " (chicken-version)))
22 |
23 | (scmxlate-uncall
24 | define-namespace-anchor
25 | require
26 | tex2page
27 | )
28 |
29 | (scmxlate-ignoredef-rename
30 | (ensure-file-deleted delete-file*))
31 |
32 | (scmxlate-rename
33 | (seconds->date seconds->local-time)
34 | )
35 |
36 | (define *tex2page-namespace* (interaction-environment))
37 |
38 | (define (list* . args)
39 | (let ((a (car args)) (d (cdr args)))
40 | (if (null? d) a
41 | (cons a (apply list* d)))))
42 |
43 | (define (append! l1 l2)
44 | (cond ((null? l1) l2)
45 | ((null? l2) l1)
46 | (else (let loop ((r1 l1))
47 | (let ((cdr-r1 (cdr r1)))
48 | (cond ((null? cdr-r1) (set-cdr! r1 l2) l1)
49 | (else (loop cdr-r1))))))))
50 |
51 | (define (reverse! s)
52 | (let loop ((s s) (r '()))
53 | (if (null? s) r
54 | (let ((d (cdr s)))
55 | (set-cdr! s r)
56 | (loop d s)))))
57 |
58 | (define (index-of s x)
59 | (let loop ((s s) (i 0))
60 | (cond ((null? s) false)
61 | ((eq? (car s) x) i)
62 | (else (loop (cdr s) (+ i 1))))))
63 |
64 | (define (string-is-flanked-by-stars-p s)
65 | ;Chicken's char=? is not variadic
66 | (let ((n (string-length s)))
67 | (and (>= n 3)
68 | (char=? (string-ref s 0) #\*)
69 | (char=? (string-ref s (sub1 n)) #\*))))
70 |
71 | (define (remove y xx)
72 | (let loop ((xx xx) (r '()))
73 | (if (null? xx) (reverse! r)
74 | (let ((x (car xx)))
75 | (loop (cdr xx)
76 | (if (equal? x y) r
77 | (cons x r)))))))
78 |
79 | (define (string-upcase s)
80 | (list->string (map char-upcase (string->list s))))
81 |
82 | (define (string-trim s)
83 | (let ((orig-n (string-length s)))
84 | (let ((i 0) (n orig-n))
85 | (let loop ((k i))
86 | (cond ((>= k n) (set! i n))
87 | ((char-whitespace? (string-ref s k))
88 | (loop (+ k 1)))
89 | (else (set! i k))))
90 | (let loop ((k (- n 1)))
91 | (cond ((<= k i) (set! n (+ k 1)))
92 | ((char-whitespace? (string-ref s k))
93 | (loop (- k 1)))
94 | (else (set! n (+ k 1)))))
95 | (if (and (= i 0) (= n orig-n)) s
96 | (substring s i n)))))
97 |
98 | (define (strftime ignore d)
99 | (let ((s (time->string d))
100 | (tz (get-environment-variable "TZ")))
101 | (string-append
102 | (substring s 0 (- (string-length s) 1))
103 | (if tz (string-append " " tz) ""))))
104 |
105 | (define (date-minute v) (vector-ref v 1))
106 | (define (date-hour v) (vector-ref v 2))
107 | (define (date-day v) (vector-ref v 3))
108 | (define (date-month v) (vector-ref v 4))
109 | (define (date-year v) (vector-ref v 5))
110 |
111 | (define (ormap f s)
112 | ;Returns true if f is true of some elt in s
113 | (let loop ((s s))
114 | (if (null? s) #f
115 | (or (f (car s)) (loop (cdr s))))))
116 |
117 | (scmxlate-postamble)
118 |
119 | (define (main cla)
120 | (tex2page
121 | (and (>= (length cla) 1)
122 | (car cla))))
123 |
124 | ; Felix says: To compile, do
125 | ; csc my-tex2page -o whatever -b -O2
126 | ; This has been incorporated into scmxlate, but it
127 | ; may be better to hand-do it from the OS
128 | ; command-line.
129 |
130 | ;(scmxlate-postamble)
131 |
132 | ;(define call-tex2page
133 | ; (lambda ()
134 | ; (let ((aa (command-line-arguments))
135 | ; (n (cond-expand (compiling 1) (else 4))))
136 | ; (tex2page
137 | ; (or
138 | ; (and (>= (length aa) n)
139 | ; (list-ref aa (- n 1)))
140 | ; "--missing-arg")))))
141 |
142 | ;(call-tex2page)
143 |
--------------------------------------------------------------------------------
/dialects/make-guile-version:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Jul 18, 2003
4 | # last modified 2022-12-28
5 |
6 | sed -e 's/ / /g' tex2page.rkt |\
7 | sed -e 's/ \ *$//' |\
8 | sed -e 's/^ *$/END_OF_CURR_EXP/' > my-tex2page
9 |
10 | function ignoredef() {
11 | for f in "$@"
12 | do
13 | sed -e '/^(define \ *'$f' *$/,/^END_OF_CURR_EXP/d' my-tex2page |\
14 | sed -e '/^(define \ *('$f') *$/,/^END_OF_CURR_EXP/d' |\
15 | sed -e '/^(define \ *('$f' \ *.*$/,/^END_OF_CURR_EXP/d' |\
16 | sed -e '/^(define \ *'$f' \ *.*$/,/^END_OF_CURR_EXP/d' > .sedtmp
17 | mv .sedtmp my-tex2page
18 | done
19 | }
20 |
21 | function rename() {
22 | # echo doing rename "$@"
23 | sed -e 's/'$1'/'$2'/g' my-tex2page > .sedtmp
24 | mv .sedtmp my-tex2page
25 | }
26 |
27 | function uncall() {
28 | for f in "$@"
29 | do
30 | sed -e '/^('$f'/,/^END_OF_CURR_EXP/d' my-tex2page > .sedtmp
31 | mv .sedtmp my-tex2page
32 | done
33 | }
34 |
35 | ignoredef \
36 | '\*scheme-version\*' \
37 | '\*tex2page-namespace\*' \
38 | call-with-input-string \
39 | strftime \
40 | string-index\
41 | string-reverse-index
42 |
43 | rename '(add1' '(1+'
44 | rename '(current-seconds' '(current-time'
45 | rename '(date-day' '(tm:mday'
46 | rename '(date-hour' '(tm:hour'
47 | rename '(date-minute' '(tm:min'
48 | rename '(date-month' '(tm:mon'
49 | rename '(date-time-zone-offset' '(tm:gmtoff'
50 | rename '(date-week-day' '(tm:wday'
51 | rename '(date-year' '(tm:year'
52 | rename '(define-syntax' '(almost-define-syntax'
53 | rename '(flush-output' '(force-output'
54 | rename '(index-of' '(list-index'
55 | rename '(list\*' '(cons*'
56 | rename '(ormap' '(or-map'
57 | rename '(remove' '(delete'
58 | rename '(seconds->date' '(localtime'
59 | rename '(string->keyword' '(string->symbol'
60 | rename '(string-reverse-index' '(string-rindex'
61 | rename '(sub1' '(1-'
62 | rename '\([^-f]\)false' '\1#f'
63 | rename '\([^-:]\)null\([^?]\)' '\1`()\2'
64 | rename 'null$' '`()'
65 | rename '\([^-f]\)true' '\1#t'
66 |
67 | uncall define-namespace-anchor require tex2page
68 |
69 | sed -e '/^#!/,/^END_OF_CURR_EXP/d' my-tex2page > .sedtmp
70 | mv .sedtmp my-tex2page
71 |
72 | sed -e '/^#lang racket/,/END_OF_CURR_EXP/d' my-tex2page > .sedtmp
73 | mv .sedtmp my-tex2page
74 |
75 | cat > guile.preamble <symbol
92 | (string-append "%__"
93 | (symbol->string (car xv))))) xvxv))
94 | (res '%_*_res))
95 | \`(let ,(map (lambda (old-x x) \`(,old-x ,x)) old-xx xx)
96 | ,@(map (lambda (x v)
97 | \`(set! ,x ,v)) xx vv)
98 | (let ((,res (begin ,@ee)))
99 | ,@(map (lambda (x old-x) \`(set! ,x ,old-x)) xx old-xx)
100 | ,res)))))
101 |
102 | (define (file-or-directory-modify-seconds f) (vector-ref (stat f) 9))
103 |
104 | (define (read-line i)
105 | (let ((c (peek-char i)))
106 | (if (eof-object? c)
107 | c
108 | (let loop ((r (quote ())))
109 | (let ((c (read-char i)))
110 | (if (or (eof-object? c) (char=? c #\newline))
111 | (list->string (reverse! r))
112 | (loop (cons c r))))))))
113 |
114 | (define-macro almost-define-syntax
115 | (lambda (name proc)
116 | \`(define-macro ,name
117 | (lambda _args
118 | (let ((datum->syntax (lambda (x y) y))
119 | (syntax->datum (lambda (x) x)))
120 | (,proc (cons 'defstruct _args)))))))
121 |
122 | (define (main args)
123 | (tex2page
124 | (and (>= (length args) 2)
125 | (list-ref args 1))))
126 | EOF
127 |
128 | sed -e '1s/^/DUMMY_LINE\n/' my-tex2page |\
129 | sed -e '1r guile.preamble' |\
130 | sed -e '1d' |\
131 | sed -e 's/^END_OF_CURR_EXP.*$//' > .sedtmp
132 | mv .sedtmp my-tex2page
133 | chmod +x my-tex2page
134 |
135 | rm -f guile.preamble
136 |
--------------------------------------------------------------------------------
/faq.tex:
--------------------------------------------------------------------------------
1 | \input texrc
2 | \input btxmac
3 | \input texnames.sty
4 | \let\TZPtexlayout=1
5 | \activettchar`
6 |
7 | \newcount\qno
8 |
9 | \def\question{\medbreak
10 | \global\advance\qno by 1
11 | \noindent
12 | {\bf \the\qno.}\enspace
13 | \bgroup
14 | \aftergroup\egroup
15 | \aftergroup\smallskip
16 | \it}
17 |
18 | %\title{TeX2page \\~\\ Frequently Asked Questions}
19 | \def\TZPtitle{TeX2page FAQ}
20 | \title{\TeX2page \\ Frequently Asked Questions}
21 |
22 | \medskip
23 |
24 | {\question Do I need to know Scheme or Common Lisp in order to be able
25 | to use \TeX2page?}
26 |
27 | No. Even for those occasions where you need to
28 | modify \TeX2page’s behavior, basic \TeX\ macros are
29 | usually sufficient. However, if you wish to extend
30 | \TeX2page in peculiar and/or idiosyncratic ways,
31 | familiarity with Scheme or Common Lisp will help.
32 |
33 | {\question But I do need Scheme or Common Lisp to run \TeX2page?}
34 |
35 | You need either a Scheme dialect or Common Lisp.
36 |
37 | {\question This sounds like too much work! Look, I am on Linux or Cygwin.
38 | Shouldn’t I be able to install \TeX2page like other GNU software and have it
39 | “just work”,
40 | instead of worrying about Scheme, Common Lisp and their myriad
41 | dialects?}
42 |
43 | Well, you do need to have a Scheme or Common Lisp installed on your system.
44 | Type `./configure --help` for guidance.
45 |
46 | {\question I need a converter for my \LaTeX\ documents.
47 | Doesn’t \TeX2page convert only plain \TeX?}
48 |
49 | \TeX2page converts \LaTeX\ as well as plain \TeX\ documents.
50 |
51 | {\question Do I need to make changes to my document to make it
52 | suitable for \TeX2page?}
53 |
54 | Typically, this isn’t necessary. If \TeX2page
55 | fails to convert your legacy document, you can put
56 | \TeX2page-specific information in a `.t2p` file, without
57 | modifying the legacy document. See the
58 | \urlh{index.html}{manual}.
59 |
60 | {\question Why does my document have broken images?}
61 |
62 | \TeX2page makes images using a combination of \TeX,
63 | Dvips, Ghostscript and the NetPBM library. Make sure
64 | you have running versions of these programs on your
65 | system. They are all freely available from the
66 | Web.
67 |
68 | {\question Couldn’t the images be a bit larger?}
69 |
70 | Use the `\imgpreamble` command to specify a higher
71 | magnification for your images.
72 |
73 | {\question How do I make my HTML file be a little
74 | less drab?}
75 |
76 | You need style sheets. The \TeX2page manual tells you
77 | how to incorporate them.
78 |
79 | {\question Is there a way to avoid having my converted
80 | document mention \TeX2page?}
81 |
82 | Read about the `\TZPcolophoncredit` flag in the
83 | \TeX2page manual.
84 |
85 | {\question Do I really have to read the \TeX2page
86 | manual?}
87 |
88 | I suppose you could consult it only when you run into
89 | problems, but do consider reading it. It is a fine
90 | manual.
91 |
92 | {\question Why can’t I just use \LaTeX2HTML~\cite{latex2html}?}
93 |
94 | You certainly can. Converting TeX source to other
95 | formats inevitably involves compromises, so different
96 | converters will have different strengths, different
97 | approaches to extensibility, and
98 | appeal to different tastes. You should pick the one
99 | that best fits your needs.
100 |
101 | {\question What are some of the other converters?}
102 |
103 | HeVeA~\cite{hevea}, \TeX4ht~\cite{tex4ht}, TtH~\cite{tth}.
104 |
105 | {\question I like getting both a
106 | printable and an online document from the same source.
107 | But hasn’t Texinfo~\cite{texinfo} already solved that problem?}
108 |
109 | Actually the problem \TeX2page attempts to solve is getting
110 | high-quality online texts {\em from
111 | arbitrary \TeX\
112 | source} (which we already know to produce high-quality
113 | printed output). Texinfo requires its source to be in a
114 | restricted Texinfo format.
115 |
116 | {\question OK. I am ready to give \TeX2page a try.
117 | Where do I get it?}
118 |
119 | The official \TeX2page website is
120 | \urlh{index.html}{\path{http://ds26gte.github.io/tex2page/index.html}}.
121 | The download link is just below the title. Appendix D
122 | contains installation instructions.
123 |
124 | \beginsection Works cited
125 |
126 | \bibliographystyle{plain}
127 | \bibliography{tex2page}
128 |
129 | \bye
130 |
--------------------------------------------------------------------------------
/dialects/scheme48-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change: 2022-12-28
2 |
3 | (scmxlate-insert
4 | ";The structures
5 | ;
6 | ;c-system-function
7 | ;extended-ports
8 | ;posix
9 | ;
10 | ;need to be open before you can run the code in this file
11 | ")
12 |
13 | (define *scheme-version* "Scheme 48")
14 |
15 | (define *int-corresp-to-nul*
16 | (- (char->integer #\a) 97))
17 |
18 | (define (s48-int-to-char n)
19 | (integer->char
20 | (+ n *int-corresp-to-nul*)))
21 |
22 | (define (s48-char-to-int c)
23 | (- (char->integer c)
24 | *int-corresp-to-nul*))
25 |
26 | (scmxlate-rename
27 | (char->integer s48-char-to-int)
28 | (integer->char s48-int-to-char)
29 | (substring subseq)
30 | )
31 |
32 | (define (get-arg1 ) #f)
33 |
34 | (scmxlate-uncall
35 | require
36 | main
37 | )
38 |
39 | (define-syntax when
40 | (lambda (e r c)
41 | `(if ,(cadr e) (begin ,@(cddr e)))))
42 |
43 | (define-syntax unless
44 | (lambda (e r c)
45 | `(if (not ,(cadr e)) (begin ,@(cddr e)))))
46 |
47 | (define-syntax fluid-let
48 | (lambda (e r c)
49 | (let ((xvxv (cadr e))
50 | (ee (cddr e)))
51 | (let ((xx (map car xvxv))
52 | (vv (map cadr xvxv))
53 | (old-xx (map (lambda (xv)
54 | (string->symbol
55 | (string-append "%__"
56 | (symbol->string (car xv))))) xvxv))
57 | (res '%_*_res))
58 | `(let ,(map (lambda (old-x x) `(,old-x ,x)) old-xx xx)
59 | ,@(map (lambda (x v)
60 | `(set! ,x ,v)) xx vv)
61 | (let ((,res (begin ,@ee)))
62 | ,@(map (lambda (x old-x) `(set! ,x ,old-x)) xx old-xx)
63 | ,res))))))
64 |
65 | ;(define-macro when
66 | ; (lambda (b . ee)
67 | ; `(if ,b (begin ,@ee))))
68 | ;
69 | ;(define-macro unless
70 | ; (lambda (b . ee)
71 | ; `(if (not ,b) (begin ,@ee))))
72 | ;
73 | ;(define-macro fluid-let
74 | ; (lambda (xvxv . ee)
75 | ; (let ((xx (map car xvxv))
76 | ; (vv (map cadr xvxv))
77 | ; (old-xx (map (lambda (xv)
78 | ; (string->symbol
79 | ; (string-append "%__"
80 | ; (symbol->string (car xv))))) xvxv))
81 | ; (res '%_*_res))
82 | ; `(let ,(map (lambda (old-x x) `(,old-x ,x)) old-xx xx)
83 | ; ,@(map (lambda (x v)
84 | ; `(set! ,x ,v)) xx vv)
85 | ; (let ((,res (begin ,@ee)))
86 | ; ,@(map (lambda (x old-x) `(set! ,x ,old-x)) xx old-xx)
87 | ; ,res)))))
88 |
89 | (define (list* . args)
90 | (let ((a (car args)) (d (cdr args)))
91 | (if (null? d) a
92 | (cons a (apply list* d)))))
93 |
94 | (define (reverse! s)
95 | (let loop ((s s) (r '()))
96 | (if (null? s) r
97 | (let ((d (cdr s)))
98 | (set-cdr! s r)
99 | (loop d s)))))
100 |
101 | (define (append! s1 s2)
102 | ;appends s1 and s2 destructively (s1 may be modified)
103 | (if (null? s1) s2
104 | (let loop ((r1 s1))
105 | (if (null? r1) (error 'append! s1 s2)
106 | (let ((r2 (cdr r1)))
107 | (if (null? r2)
108 | (begin
109 | (set-cdr! r1 s2)
110 | s1)
111 | (loop r2)))))))
112 |
113 | (define (ormap f s)
114 | ;Returns true if f is true of some elt in s
115 | (let loop ((s s))
116 | (if (null? s) #f
117 | (or (f (car s)) (loop (cdr s))))))
118 |
119 | (define (subseq s i . z)
120 | (let ((f (if (pair? z) (car z) (string-length s))))
121 | (substring s i f)))
122 |
123 | (define (read-line i)
124 | (let ((c (peek-char i)))
125 | (if (eof-object? c) c
126 | (let loop ((r '()))
127 | (let ((c (read-char i)))
128 | (if (or (eof-object? c) (char=? c #\newline))
129 | (list->string (reverse! r))
130 | (loop (cons c r))))))))
131 |
132 | (define (file-exists? f)
133 | (accessible? f (access-mode read)))
134 |
135 | (define (flush-output . z) #f)
136 |
137 | (define (call-with-input-string s p)
138 | (p (make-string-input-port s)))
139 |
140 | (define (file-or-directory-modify-seconds f)
141 | (time-seconds
142 | (file-info-last-modification
143 | (get-file-info f)))
144 | ;(file-info:mtime (file-info f))
145 | )
146 |
147 | '(define (seconds-to-human-time secs)
148 | (time->string
149 | (make-time secs)))
150 |
151 | (scmxlate-include "seconds-to-date.scm")
152 |
153 | (define (current-seconds ) #f)
154 |
155 | (define *tex2page-namespace* (scheme-report-environment 5))
156 |
157 | (define (do-evalh s)
158 | (let ((f "./.evalh.scm"))
159 | (call-with-output-file f
160 | (lambda (o)
161 | (display s o)))
162 | (load f)
163 | (unlink f)))
164 |
165 | (scmxlate-include "temp-file.scm")
166 | (scmxlate-include "with-port.scm")
167 |
--------------------------------------------------------------------------------
/tex2page-doc-mac.tex:
--------------------------------------------------------------------------------
1 | % last change: 2022-12-30
2 | % Dorai Sitaram
3 | %
4 | %
5 |
6 | \input texrc
7 |
8 | %\magnification\magstephalf
9 | \input miniltx
10 | \input graphicx
11 | \input coloraug
12 | \resetatcatcode
13 | \input btxmac
14 |
15 | \input eval4tex
16 |
17 | \input path.sty
18 | \input texnames.sty
19 |
20 | \let\TZPtexlayout=1
21 |
22 | \advance\hoffset .5truein
23 | \advance\hsize -1truein
24 |
25 | \overfullrule0pt
26 | \tocdepth 1
27 |
28 | \ifx\suppressfontnotfounderror\UnDeFiNeD\else
29 | \suppressfontnotfounderror=1
30 | \fi
31 |
32 | \def\tthook{\catcode`\|=0 \def\|{\char`\|}\def\ {·}}
33 |
34 | \ifx\shipout\UnDeFiNeD\else
35 | \ifx\XeTeXversion\UnDeFiNeD
36 | \def\XeTeX{Xe\TeX}\else
37 | \def\XeTeX{X\kern-0.125em\lower.5ex\hbox{Ǝ}\kern-0.1667em\TeX}\fi
38 | \def\ConTeXt{Con\TeX t}
39 | \fi
40 |
41 | \input like-plt-logo
42 |
43 | \def\beginmulticols#1{}
44 | \def\endmulticols{}
45 |
46 | \ifx\shipout\UnDeFiNeD\else
47 | \IfFileExists{mimulcol}{\input mimulcol }{}
48 | \fi
49 |
50 | \ifx\shipout\UnDeFiNeD
51 | \headline={\folio, ~~ \urlh{#ToC}{ToC}, ~~ \urlh{#Index}{Index}}
52 | \footline={\the\headline}
53 | %\footline={\folio, ~~ \urlh{#ToC}{ToC}, ~~ \urlh{#Index}{Index}}
54 | \fi
55 |
56 | \def\meta[#1]{\leavevmode\hbox{\em #1}}
57 |
58 | \let\c\centerline
59 |
60 | \IfFileExists{./t2p4plt}{\input ./t2p4plt }{}
61 |
62 | \def\proto#1#2#3{\noindent
63 | \hbox{{\tt(#1}\spaceifnotempty{#2}{\it#2}{\tt)}%
64 | \qquad ;#3}\par}
65 |
66 | % We want images to be a bit bigger
67 |
68 | \ifx\shipout\UnDeFiNeD
69 | \imgpreamble
70 | \magnification\magstep2
71 | \endimgpreamble
72 | \fi
73 |
74 | \ifx\shipout\UnDeFiNeD
75 | \imgdef\um{$\mu$m}
76 | \else
77 | \def\um{$\mu$m}
78 | \fi
79 |
80 | \newdimen\templen
81 | \newbox\tempbox
82 |
83 | \def\spaceifnotempty#1{%
84 | \setbox\tempbox\hbox{#1}%
85 | \templen\wd\tempbox
86 | \ifdim\templen>0pt{\ }\fi}
87 |
88 | %\ifx\shipout\UnDeFiNeD\else
89 | %\def\fontstem#1{\expandafter\fontstemQii\fontname#1 \end}%
90 | %\def\fontstemQii#1 #2\end{#1 }%
91 | %\font\twelvebf \fontstem\tenbf at 12pt
92 | %\fi
93 |
94 | % symbol footnotes
95 |
96 | \def\fnsymbol#1{%
97 | % #1 is between 1 and 9 inclusive
98 | \ifcase#1\or
99 | *\or
100 | \dag\or
101 | \ddag\or
102 | \S\or
103 | \P\or
104 | $\Vert$\or
105 | **\or
106 | \dag\dag\or
107 | \ddag\ddag
108 | \fi}
109 |
110 | %
111 | \ifx\shipout\UnDeFiNeD\else
112 | \def\raggedleft{%
113 | \leftskip 0pt plus 1fil
114 | \parfillskip 0pt
115 | }
116 | \fi
117 | %
118 |
119 | \def\quote{\bgroup\narrower\smallbreak\noindent}
120 | \def\endquote{\smallbreak\egroup\noindent}
121 |
122 | % \xrdef, as in Eplain
123 |
124 | %\def\xrdef#1{\xrtag{#1}{\folio}}
125 |
126 | \let\n\noindent
127 | \let\f\numberedfootnote
128 | \let\p\verb
129 | \let\q\scm
130 |
131 | \ifx\TZPcommonlisp 1
132 | \eval{
133 | (defun display (&rest ee) (apply #'princ ee))
134 | }
135 | \fi
136 |
137 | \activettchar`
138 |
139 | \let\maybeendinput\relax
140 | \ifx\shipout\UnDeFiNeD\else
141 | \let\maybeendinput\endinput\fi
142 | \maybeendinput
143 |
144 | % Following only for TeX2page:
145 |
146 | %\parskip=.5em
147 | \parskip=5pt
148 |
149 | %\inputcss https://fonts.googleapis.com/css?family=Special+Elite
150 |
151 | % Some readymade stylesheets are
152 | % http://www.w3.org/StyleSheets/Core/{Chocolate,
153 | % Midnight, Modernist, Oldstyle, Steely, Swiss,
154 | % Traditional, Ultramarine}
155 |
156 | %\inputcss http://www.w3.org/StyleSheets/Core/Oldstyle
157 |
158 | \slatexlikecomments
159 |
160 | \ifx\TZPcommonlisp 1
161 | \evalq{
162 | (defun all-blanks-p (s)
163 | (every (lambda (c) (or (char= c #\space) (char= c #\tab)
164 | (not (graphic-char-p c))))
165 | s))
166 | }
167 | \else
168 | \evalq{
169 | (define princ display)
170 |
171 | (define all-blanks-p
172 | (lambda (s)
173 | (let loop ((L (string->list s)))
174 | (if (null? L) #t
175 | (let ((c (car L)))
176 | (if (char-whitespace? c) (loop (cdr L))
177 | #f))))))
178 | }
179 | \fi
180 |
181 | \evalq{
182 | (tex2page "texample")
183 | (tex2page "mpexample")
184 | }
185 |
186 | \ifx\TZPcommonlisp 1
187 | \evalq{
188 | (unless (probe-file "story.hlog") (tex2page "story"))
189 | }\else
190 | \evalq{
191 | (if (not (file-exists? "story.hlog")) (tex2page "story") 0)
192 | }\fi
193 |
194 | % make it easy for the search engines to find us
195 | \htmlheadonly
196 |
198 |
199 |
200 |
201 |
202 | \endhtmlheadonly
203 |
204 | \ifx\TZPcommonlisp 1
205 | \def\spaceifnotempty{\eval{
206 | (let ((x (ungroup (get-token))))
207 | (unless (all-blanks-p x)
208 | (princ (code-char 92))
209 | (princ "space")))}}
210 | \else
211 | \def\spaceifnotempty{\eval{
212 | (let ((x (ungroup (get-token))))
213 | (if (not (all-blanks-p x))
214 | (begin (display (integer->char 92))
215 | (display "space"))
216 | 0))
217 | }}
218 | \fi
219 |
--------------------------------------------------------------------------------
/dialects/scsh-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ;last change: 2022-12-28
2 |
3 | (scmxlate-cond
4 | ((eqv? *operating-system* 'unix)
5 | (scmxlate-insert
6 | "\":\";exec scsh -s $0 \"$@\"
7 | ")))
8 |
9 |
10 | (define *scheme-version*
11 | (string-append "Scsh " scsh-version-string))
12 |
13 | (define *tex2page-namespace* (interaction-environment))
14 |
15 | (scmxlate-uncall
16 | require
17 | )
18 |
19 | (define *int-corresp-to-nul*
20 | (- (char->integer #\a) 97))
21 |
22 | (define scsh-int-to-char
23 | (lambda (n)
24 | (integer->char
25 | (+ n *int-corresp-to-nul*))))
26 |
27 | (define scsh-char-to-int
28 | (lambda (c)
29 | (- (char->integer c)
30 | *int-corresp-to-nul*)))
31 |
32 | (scmxlate-rename
33 | (char->integer scsh-char-to-int)
34 | (integer->char scsh-int-to-char)
35 | (seconds->date date)
36 | ;(open-input-string make-string-input-port)
37 | )
38 |
39 | (scmxlate-rename-define
40 | (*january-number* 0)
41 | (*anno-domini-at-0* 1900))
42 |
43 | (define string->list
44 | ;native procedure is buggy!
45 | (lambda (s)
46 | (let loop ((i (- (string-length s) 1)) (r '()))
47 | (if (< i 0) r
48 | (loop (- i 1) (cons (string-ref s i) r))))))
49 |
50 | (define get-arg1
51 | (lambda ()
52 | (and (> (length command-line-arguments) 0)
53 | (car command-line-arguments))))
54 |
55 | (define-syntax when
56 | (lambda (e r c)
57 | `(if ,(cadr e) (begin ,@(cddr e)))))
58 |
59 | (define-syntax unless
60 | (lambda (e r c)
61 | `(if (not ,(cadr e)) (begin ,@(cddr e)))))
62 |
63 | (define-syntax fluid-let
64 | (lambda (e r c)
65 | (let ((xvxv (cadr e))
66 | (ee (cddr e)))
67 | (let ((xx (map car xvxv))
68 | (vv (map cadr xvxv))
69 | (old-xx (map (lambda (xv)
70 | (string->symbol
71 | (string-append "%__"
72 | (symbol->string (car xv))))) xvxv))
73 | (res '%_*_res))
74 | `(let ,(map (lambda (old-x x) `(,old-x ,x)) old-xx xx)
75 | ,@(map (lambda (x v)
76 | `(set! ,x ,v)) xx vv)
77 | (let ((,res (begin ,@ee)))
78 | ,@(map (lambda (x old-x) `(set! ,x ,old-x)) xx old-xx)
79 | ,res))))))
80 |
81 | (define do-evalh
82 | (lambda (s)
83 | (let ((f (create-temp-file)))
84 | (call-with-output-file f
85 | (lambda (o)
86 | (display s o)))
87 | (load f)
88 | ;(delete-file f)
89 | )))
90 |
91 |
92 | (define andmap
93 | (lambda (f s)
94 | (let loop ((s s))
95 | (if (null? s) #t
96 | (and (f (car s)) (loop (cdr s)))))))
97 |
98 | (define ormap
99 | (lambda (f s)
100 | ;Returns true if f is true of some elt in s
101 | (let loop ((s s))
102 | (if (null? s) #f
103 | (or (f (car s)) (loop (cdr s)))))))
104 |
105 |
106 | (define call-with-input-string
107 | (lambda (s p)
108 | (p (make-string-input-port s))))
109 |
110 | (define with-output-to-port
111 | (lambda (o th)
112 | (with-current-output-port o (th))))
113 |
114 | (define file-or-directory-modify-seconds
115 | (lambda (f)
116 | (file-info:mtime (file-info f))))
117 |
118 | (define date-day date:month-day)
119 | (define date-hour date:hour)
120 | (define date-minute date:minute)
121 | (define date-month date:month)
122 | (define date-year date:year)
123 |
124 | (define strftime-like
125 | (lambda (fmt dt)
126 | (format-date
127 | "~a, ~b ~d, ~Y, ~I:~M ~p ~Z" dt)))
128 |
129 | (define skip-whitespace
130 | (lambda (i)
131 | (let loop ()
132 | (if (char-whitespace? (peek-char i))
133 | (begin (read-char i) (loop))))))
134 |
135 | (define system
136 | (lambda (s)
137 | (let ((i (make-string-input-port s)))
138 | (let loop ((big-r '()) (r '()))
139 | (let ((c (read-char i)))
140 | (cond ((eof-object? c)
141 | (run ,(reverse! (cons (list->string (reverse! r)) big-r))))
142 | ((char-whitespace? c)
143 | (skip-whitespace i)
144 | (loop (cons (list->string (reverse! r)) big-r) '()))
145 | (else
146 | (loop big-r (cons c r)))))))))
147 |
148 | ;(define system
149 | ;;why doesn't this work?
150 | ; (lambda (s)
151 | ; (let ((i (make-string-input-port
152 | ; (string-append "(run (" s "))"))))
153 | ; (eval (read i) (interaction-environment))
154 | ; (close-input-port i))))
155 |
156 | (define kpsewhich
157 | (lambda (f)
158 | (let ((tmpf (string-append *aux-dir/* *jobname* "-Z-Z.temp")))
159 | (run (kpsewhich ,f)
160 | (> ,tmpf))
161 | (let ((f (call-with-input-file tmpf
162 | (lambda (i) (read-line i)))))
163 | (delete-file tmpf)
164 | (if (eof-object? f) #f
165 | (let ((f (string-trim-blanks f)))
166 | (cond ((= (string-length f) 0) #f)
167 | ((file-exists? f) f)
168 | (else #f))))))))
169 |
170 | (define ps-to-img/gif
171 | (lambda (ps-file f)
172 | (let* ((f-ppm (string-append f ".ppm"))
173 | (f-ppm-tmp (string-append f ".ppm.tmp"))
174 | (f-gif (string-append f ".gif"))
175 | (output-file (string-append "-sOutputFile=" f-ppm)))
176 | (run (,*ghostscript* -q -dBATCH -dNOPAUSE -dNO_PAUSE
177 | -sDEVICE=ppmraw ,output-file ,ps-file quit.ps))
178 | (run (pnmcrop ,f-ppm)
179 | (> ,f-ppm-tmp))
180 | (run (ppmquant 256)
181 | (< ,f-ppm-tmp)
182 | (> ,f-ppm))
183 | (run (ppmtogif -transparent rgb:ff/ff/ff)
184 | (< ,f-ppm)
185 | (> ,f-gif))
186 | (for-each
187 | (lambda (e)
188 | (ensure-file-deleted (string-append f e)))
189 | '(".ppm" ".ppm.tmp")))))
190 |
191 | (define eof
192 | (read (make-string-input-port "")))
193 |
194 | (scmxlate-postamble)
195 |
196 | (tex2page (get-arg1))
197 |
--------------------------------------------------------------------------------
/colorxe.tex:
--------------------------------------------------------------------------------
1 | % Last modified 2018-06-28
2 | % Dorai Sitaram
3 |
4 | \def\colorQwithmodel[#1]#2{%
5 | \edef\colorQmodel{#1}%
6 | \edef\colorQvalues{#2}%
7 | \colorQconvertmodel
8 | \edef\colorQtemp{\noexpand\colorQorig[\colorQmodel]{\colorQvalues}}%
9 | \colorQtemp}
10 |
11 | \def\definecolor#1#2#3{%
12 | \edef\colorQmodel{#2}%
13 | \edef\colorQvalues{#3}%
14 | \colorQconvertmodel
15 | \edef\colorQtemp{\noexpand\definecolorQorig{#1}{\colorQmodel}{\colorQvalues}}%
16 | \colorQtemp}
17 |
18 | \def\colorQconvertmodel{%
19 | %
20 | % Plain-TeX versions of xcolor.sty's cmy, Gray, Hsb, HSB, HTML,
21 | % wave.
22 | %
23 | \edef\colorQmodelcmy{cmy}%
24 | \edef\colorQmodelGray{Gray}%
25 | \edef\colorQmodelHsb{Hsb}%
26 | \edef\colorQmodelHSB{HSB}%
27 | \edef\colorQmodelHTML{HTML}%
28 | \edef\colorQmodelwave{wave}%
29 | %
30 | % hsl and Hsl: like CSS, but fractions instead of percentages.
31 | %
32 | \edef\colorQmodelhsl{hsl}%
33 | \edef\colorQmodelHsl{Hsl}%
34 | %
35 | \ifx\colorQmodel\colorQmodelcmy
36 | \expandafter\colorQconvertcmy\colorQvalues\relax
37 | \else\ifx\colorQmodel\colorQmodelGray
38 | \expandafter\colorQconvertGray\colorQvalues\relax
39 | \else\ifx\colorQmodel\colorQmodelHsb
40 | \expandafter\colorQconvertHsb\colorQvalues\relax
41 | \else\ifx\colorQmodel\colorQmodelHSB
42 | \expandafter\colorQconvertHSB\colorQvalues\relax
43 | \else\ifx\colorQmodel\colorQmodelHTML
44 | \expandafter\colorQconvertHTML\colorQvalues\relax
45 | \else\ifx\colorQmodel\colorQmodelwave
46 | \expandafter\colorQconvertwave\colorQvalues\relax
47 | \else\ifx\colorQmodel\colorQmodelhsl
48 | \expandafter\colorQconverthsl\colorQvalues\relax
49 | \else\ifx\colorQmodel\colorQmodelHsl
50 | \expandafter\colorQconvertHsl\colorQvalues\relax
51 | \fi\fi\fi\fi\fi\fi\fi\fi}
52 |
53 | % cmy
54 |
55 | {\catcode`\@=11
56 | \gdef\colorQconvertcmy #1,#2,#3\relax{%
57 | %
58 | \dimen@=#1\p@
59 | \advance\dimen@ -1\p@
60 | \multiply\dimen@ -1
61 | \edef\colorQred{\strip@pt\dimen@}%
62 | %
63 | \dimen@=#2\p@
64 | \advance\dimen@ -1\p@
65 | \multiply\dimen@ -1
66 | \edef\colorQgreen{\strip@pt\dimen@}%
67 | %
68 | \dimen@=#3\p@
69 | \advance\dimen@ -1\p@
70 | \multiply\dimen@ -1
71 | \edef\colorQblue{\strip@pt\dimen@}%
72 | %
73 | \edef\colorQmodel{rgb}%
74 | \edef\colorQvalues{\colorQred,\colorQgreen,\colorQblue}}}
75 |
76 | % Gray
77 |
78 | {\catcode`\@=11
79 | \gdef\colorQconvertGray #1\relax{%
80 | \dimen@=#1\p@
81 | \divide\dimen@ 15
82 | \edef\colorQgray{\strip@pt\dimen@}%
83 | %
84 | \edef\colorQmodel{gray}%
85 | \edef\colorQvalues{\colorQgray}}}
86 |
87 | % Hsb
88 |
89 | {\catcode`\@=11
90 | \gdef\colorQconvertHsb #1,#2,#3\relax{%
91 | \dimen@=#1\p@
92 | \divide\dimen@ 360
93 | \edef\colorQhue{\strip@pt\dimen@}%
94 | %
95 | \edef\colorQmodel{hsb}%
96 | \edef\colorQvalues{\colorQhue,#2,#3}}}
97 |
98 | % HSB
99 |
100 | {\catcode`\@=11
101 | \gdef\colorQconvertHSB #1,#2,#3\relax{%
102 | %
103 | \dimen@=#1\p@
104 | \divide\dimen@ 240
105 | \edef\colorQhue{\strip@pt\dimen@}%
106 | %
107 | \dimen@=#2\p@
108 | \divide\dimen@ 240
109 | \edef\colorQsat{\strip@pt\dimen@}%
110 | %
111 | \dimen@=#3\p@
112 | \divide\dimen@ 240
113 | \edef\colorQbright{\strip@pt\dimen@}%
114 | %
115 | \edef\colorQmodel{hsb}%
116 | \edef\colorQvalues{\colorQhue,\colorQsat,\colorQbright}}}
117 |
118 | % HTML
119 |
120 | \def\colorQconvertHTML #1#2#3#4#5#6\relax{%
121 | \edef\colorQred{\number"#1#2}%
122 | \edef\colorQgreen{\number"#3#4}%
123 | \edef\colorQblue{\number"#5#6}%
124 | %
125 | \edef\colorQmodel{RGB}%
126 | \edef\colorQvalues{\colorQred,\colorQgreen,\colorQblue}}
127 |
128 | % wave
129 |
130 | {\catcode`@=11
131 | \gdef\colorQconvertwave #1\relax{%
132 | %
133 | \dimen@=#1\p@
134 | \ifdim\dimen@<362.857\p@
135 | \dimen@=5\p@
136 | \else\ifdim\dimen@=362.857\p@
137 | \dimen@=5\p@
138 | \else\ifdim\dimen@<440\p@
139 | \advance\dimen@ -440\p@
140 | \divide\dimen@ -60
141 | \advance\dimen@ 4\p@
142 | \else\ifdim\dimen@<490\p@
143 | \advance\dimen@ -440\p@
144 | \divide\dimen@ 50
145 | \multiply\dimen@ -1
146 | \advance\dimen@ 4\p@
147 | \else\ifdim\dimen@<510\p@
148 | \advance\dimen@ 510\p@
149 | \divide\dimen@ -20
150 | \advance\dimen@ 2\p@
151 | \else\ifdim\dimen@<580\p@
152 | \advance\dimen@ -510\p@
153 | \divide\dimen@ -70
154 | \multiply\dimen@ -1
155 | \advance\dimen@ 2\p@
156 | \else\ifdim\dimen@<645\p@
157 | \advance\dimen@ -645\p@
158 | \divide\dimen@ -65
159 | \else
160 | \dimen@=0\p@
161 | \fi\fi\fi\fi\fi\fi\fi
162 | \divide\dimen@ 6
163 | \edef\colorQhue{\strip@pt\dimen@}%
164 | %
165 | \dimen@=#1\p@
166 | \ifdim\dimen@<362.857\p@
167 | \dimen@=0\p@
168 | \else\ifdim\dimen@=362.857\p@
169 | \dimen@=0\p@
170 | \else\ifdim\dimen@<420\p@
171 | \advance\dimen@ 380\p@
172 | \divide\dimen@ 40
173 | \multiply\dimen@ .7
174 | \advance\dimen@ .3\p@
175 | \else\ifdim\dimen@<700\p@
176 | \dimen@=1\p@
177 | \else\ifdim\dimen@=700\p@
178 | \dimen@=1\p@
179 | \else\ifdim\dimen@<814.285\p@
180 | \advance\dimen@ -780
181 | \divide\dimen@ -80
182 | \multiply\dimen@ .7
183 | \advance\dimen@ .3\p@
184 | \else
185 | \dimen@=0\p@
186 | \fi\fi\fi\fi\fi\fi
187 | \edef\colorQbright{\strip@pt\dimen@}%
188 | %
189 | \edef\colorQmodel{hsb}%
190 | \edef\colorQvalues{\colorQhue,1,\colorQbright}}}
191 |
192 | % hsl
193 |
194 | {\catcode`\@=11
195 | \gdef\colorQconverthsl #1,#2,#3\relax{%
196 | %
197 | \dimen@=#3\p@
198 | \multiply\dimen@ 2
199 | \advance\dimen@ -1\p@
200 | \ifdim\dimen@<0\p@
201 | \multiply\dimen@ -1
202 | \fi
203 | \advance\dimen@ -1\p@
204 | \multiply\dimen@ -1
205 | \dimen@=#2\dimen@
206 | \advance\dimen@ #3\p@
207 | \advance\dimen@ #3\p@
208 | \divide\dimen@ 2
209 | \edef\colorQbright{\strip@pt\dimen@}%
210 | %
211 | \count@=\dimen@
212 | \advance\dimen@ -#3\p@
213 | \multiply\dimen@ 2
214 | \multiply\dimen@ 4096
215 | \divide\dimen@ \count@
216 | \multiply\dimen@ 16
217 | \edef\colorQsat{\strip@pt\dimen@}%
218 | %
219 | \edef\colorQmodel{hsb}%
220 | \edef\colorQvalues{#1,\colorQsat,\colorQbright}}}
221 |
222 | % Hsl
223 |
224 | {\catcode`\@=11
225 | \gdef\colorQconvertHsl #1,#2,#3\relax{%
226 | \dimen@=#1\p@
227 | \divide\dimen@ 360
228 | \edef\colorQhue{\strip@pt\dimen@}%
229 | %
230 | \colorQconverthsl \colorQhue,#2,#3\relax}}
231 |
--------------------------------------------------------------------------------
/man/man1/tex2page.1:
--------------------------------------------------------------------------------
1 | .TH TEX2PAGE 1 "2016-11-16" \"last change
2 | .nh
3 | .ad l
4 | .SH NAME
5 |
6 | tex2page \- makes Web pages from LaTeX and plain-TeX documents
7 |
8 | .SH SYNOPSIS
9 |
10 | tex2page --help
11 | tex2page --version
12 | tex2page
13 |
14 | .SH DESCRIPTION
15 |
16 | The command
17 |
18 | tex2page
19 |
20 | converts the TeX source file to the HTML file
21 | .html, where is the basename of .
22 | Some auxiliary HTML files and some image files may also be
23 | created.
24 |
25 | The argument can be a full or relative pathname. If
26 | the latter, it is reckoned relative to the current directory.
27 | The extension may be omitted if it is .tex.
28 |
29 | In order to resolve cross-references, it may be necessary to
30 | invoke tex2page a couple of times. The log displayed on the
31 | console will inform you if such is the case. This log is also
32 | saved in the file .hlog.
33 |
34 | If tex2page is called with the option ‘--help’, it prints a help
35 | message and exits.
36 |
37 | If tex2page is called with the option ‘--version’, it prints
38 | version information and exits.
39 |
40 | If tex2page is called without an argument, or if the argument is
41 | neither a valid option nor an existing file, then tex2page prints
42 | a brief help message and exits. If you repeatedly (i.e., five or
43 | more times) call it faultily despite its helpful advice, tex2page
44 | will visibly lose its patience.
45 |
46 | The complete documentation for tex2page is included in the
47 | tex2page distribution, and may also be viewed on the Web at
48 |
49 | http://ds26gte.github.io/tex2page/index.html
50 |
51 | .SH SEARCH PATH FOR TeX FILES
52 |
53 | tex2page uses the same search path as TeX to search for
54 | \einput and \eopenin files. The default search path is
55 | implementation-dependent but can be changed by setting the
56 | environment variable TEXINPUTS to a list of colon-separated
57 | directories. (If you wish to merely prepend your list to the
58 | default list, end your list with a colon.)
59 |
60 | Add two trailing forward slashes to any directory in TEXINPUTS
61 | that you want to recursively search all subdirectories of.
62 |
63 | If the environment variable TEX2PAGEINPUTS is set, tex2page will
64 | use the TEX2PAGEINPUTS value as its search path instead of
65 | TEXINPUTS. TEX2PAGEINPUTS does not support the double-slash
66 | mechanism of TEXINPUTS.
67 |
68 | .SH EDITING ON ERROR
69 |
70 | If tex2page encounters a fatal error in the document, it
71 | displays the prompt
72 |
73 | Type e to edit file at point of error; x to quit
74 | ?
75 |
76 | If you type x, tex2page immediately exits.
77 |
78 | If however you type e, a text editor is fired up, showing the
79 | offending file — which may or may not be the main input file —
80 | at the line containing the error. The particular editor chosen
81 | and the arguments with which it is called depends on the
82 | environment variables TEXEDIT or EDITOR.
83 |
84 | If the environment variable TEXEDIT is set, tex2page uses its
85 | string value as the editor call to use. A possible value for
86 | TEXEDIT is "vim +%d %s". This calls the editor vim with %s
87 | replaced by the offending file’s name, and %d replaced by the
88 | number of the offending line.
89 |
90 | If TEXEDIT is not set, the value of the environment variable
91 | EDITOR is chosen as the editor. Unlike TEXEDIT
92 | which contains the editor call as a template, EDITOR contains
93 | simply the editor’s name. If EDITOR is also not set, vi is
94 | chosen as the editor.
95 |
96 | The editor specified in EDITOR is called with the arguments
97 | " + ", where is the offending file’s name and is the
98 | offending line number. It is not possible to alter the way the
99 | file and line arguments are supplied, but fortunately this style
100 | is accepted by vi, emacs, and all their clones. If you use an
101 | editor that requires a different argument style, use TEXEDIT.
102 |
103 | .SH DIRECTORY FOR HTML PAGES
104 |
105 | By default, tex2page generates its output HTML files in the
106 | current directory. You can specify a different directory by
107 | naming it in one of the following files:
108 |
109 | .hdir in the current directory, or
110 | .tex2page.hdir in the current directory, or
111 | .tex2page.hdir in your home directory;
112 |
113 | where is the basename of the input document. The
114 | first of these three files that exists overrides the rest.
115 |
116 | The name in the .hdir file can be, or contain, the TeX
117 | control-sequence \ejobname, which expands to , the
118 | basename of the input document.
119 |
120 | .SH DOCUMENT-SPECIFIC MACROS
121 |
122 | Before processing a TeX source file whose basename is
123 | , tex2page will automatically load the file
124 | .t2p, if it exists. .t2p is a good place
125 | to put macros that are specific to the HTML version of the
126 | document.
127 |
128 | .SH GENERAL MACROS
129 |
130 | tex2page recognizes some commands that are not supplied in
131 | the LaTeX or plain-TeX formats — typically these are
132 | commands that add value to the HTML output. In order to keep
133 | an input document that uses these extra commands processable
134 | by TeX, working TeX definitions are provided in the TeX macro
135 | file tex2page.tex and the LaTeX macro package file
136 | tex2page.sty. Copy these macro files from the tex2page
137 | distribution to a directory in your TEXINPUTS.
138 |
139 | Plain-TeX documents can use
140 |
141 | \einput tex2page
142 |
143 | while LaTeX documents can use
144 |
145 | \eusepackage{tex2page}
146 |
147 | .SH SYSTEM REQUIREMENTS
148 |
149 | tex2page runs on a variety of Scheme and Common Lisp
150 | implementations. It may also make use of the following external
151 | programs: BibTeX, MakeIndex, Ghostscript, Dvips, MetaPost, and
152 | the NetPBM library.
153 |
154 |
155 | .SH BUGS
156 |
157 | Email to ds26gte at yahoo dot com.
158 |
159 | https://github.com/ds26gte/tex2page/issues
160 |
161 | .SH SEE ALSO
162 |
163 | tex(1), latex(1), racket(1), bibtex(1), makeindex(1L),
164 | mpost(1).
165 |
166 | .SH COPYRIGHT
167 |
168 | Copyright 1997–2016 by Dorai Sitaram.
169 |
170 | Permission to distribute and use this work for any purpose is
171 | hereby granted provided this copyright notice is included in
172 | the copy. This work is provided as is, with no warranty of any
173 | kind.
174 |
175 | .nx
176 |
--------------------------------------------------------------------------------
/INSTALL.adoc:
--------------------------------------------------------------------------------
1 | = Installing TeX2page
2 |
3 | Get the TeX2page distribution from GitHub:
4 |
5 | git clone https://github.com/ds26gte/tex2page
6 |
7 | This produces a directory called `tex2page`, which contains,
8 | among other things, the files
9 |
10 | tex2page.rkt
11 | tex2page.lisp
12 | tex2page.tex
13 | tex2page.sty
14 |
15 | Put copies of (or link to) the files `tex2page.tex` and
16 | `tex2page.sty` in a directory that is in your `TEXINPUTS` path.
17 |
18 | Optional: Copy the file `man/man1/tex2page.1` to the `man1`
19 | subdirectory of a directory in your `MANPATH`.
20 |
21 | == Configuring TeX2page for your machine
22 |
23 | Out of the box, the script `tex2page.rkt` works in Racket;
24 | and the script `tex2page.lisp` works in whatever Common Lisp the environment
25 | variable `LISP` is set to (if `LISP` is not set, ECL is assumed).
26 |
27 | You may put these scripts in your
28 | PATH, possibly renaming whichever of them you prefer to
29 | `tex2page`. (`tex2page` is softlinked to `tex2page.rkt` in the
30 | distribution.)
31 |
32 | In general, type
33 |
34 | ./configure --help
35 |
36 | to see the list of dialects the `configure` script supports. (So
37 | you don't get overwhelmed, you will also be shown some
38 | suggestions tailored to your machine.)
39 |
40 | If your dialect `D` is mentioned, type
41 |
42 | ./configure --dialect=D
43 |
44 | This will create a `tex2page` configured for your dialect. You
45 | may put in your PATH. (For Windows, a batch file `tex2page.bat`
46 | is also created in some instances.)
47 |
48 | If you use Common Lisp, you can avoid configuration by
49 | setting the environment variable `LISP` to one of: `abcl`,
50 | `allegro`, `clasp`, `clisp`, `clozure`, `cmucl`, `ecl` (default), `mkcl`, `sbcl`.
51 | This makes `tex2page.lisp` equivalent to whatever
52 |
53 | ./configure --dialect=$LISP
54 |
55 | would have produced.
56 |
57 | === Racket and Common Lisp
58 |
59 | Although TeX2page works out of the box for Racket and Common
60 | Lisp, you can still "`configure`" for them, e.g.,
61 |
62 | ./configure --dialect=racket
63 | ./configure --dialect=sbcl
64 |
65 | The first merely copies `tex2page.rkt` to `tex2page`. Similarly,
66 | the second copies `tex2page.lisp` to `tex2page`, but also embeds
67 | `LISP` to be `sbcl`.
68 |
69 | In addition, the "`dialect`" `sbcl-compiled` is also
70 | supported.
71 |
72 | ./configure --dialect=sbcl-compiled
73 |
74 | creates a `tex2page` that is a compiled version of TeX2page for
75 | SBCL. It may be a bit faster.
76 |
77 | === Scmxlate
78 |
79 | Note that `configure` may use Scmxlate, available at
80 | https://github.com/ds26gte/scmxlate. If you have Git and are
81 | connected to the Internet, `configure` will automatically fetch
82 | Scmxlate unless it finds it's already installed on your system.
83 |
84 | Configuration for Racket, Guile and the Common Lisps doesn't
85 | require Scmxlate. If you're on a Unix-like environment blessed
86 | with lots of GNU software, e.g., Linux and Cygwin, chances are
87 | you already have or can easily install one of these Schemes or
88 | Lisps. `configure --help` will tell you if you can exploit this
89 | situation and avoid Scmxlate altogether.
90 |
91 | If your dialect is not supported, or `configure` fails for whatever
92 | reason, you can invoke Scmxlate directly. First ensure that
93 | Scmxlate is installed on your system. Note down the pathname of
94 | the file `scmxlate.scm` in the unpacked `scmxlate` directory.
95 |
96 | Start your Scheme or Common Lisp in the `tex2page` directory;
97 | then explicitly load the file `scmxlate.scm`, using its correct
98 | pathname. E.g.,
99 |
100 | (load "/usr/local/lib/scmxlate/scmxlate.scm")
101 |
102 | You will be asked a couple of questions about your setup. A
103 | choice of answers will be provided, so you don't have to be too
104 | creative. When Scmxlate finishes, you will be left with a
105 | `tex2page` that is tailormade for your system.
106 |
107 | == Can't create a working script file?
108 |
109 | If you are unable to create a script file to put in your `PATH`,
110 | you may simply load `tex2page` directly into your Scheme, and
111 | then call the Scheme procedure `tex2page` on your source
112 | document, e.g.,
113 |
114 | (load "tex2page")
115 | (tex2page "jobname.tex")
116 |
117 | == Image generation
118 |
119 | (Skip this section if you're _not_ running Windows.)
120 |
121 | The image generation subprocess in TeX2page uses Ghostscript.
122 | The TeX2page code stores the name of the Ghostscript executable
123 | name in the variable `+*ghostscript*+`. For Unix, this value is
124 | `"gs"`, which is pretty standard. If you're using Windows, check
125 | that the value assigned to `+*ghostscript*+` is correct for you.
126 |
127 | == Generating the documentation
128 |
129 | The TeX2page documentation is provided in the TeX file `index.tex`.
130 | To get a PDF version of the document run, first ensure that the
131 | file `story.log` exists. If it does not, run
132 |
133 | luatex story
134 |
135 | and supply
136 |
137 | \end
138 |
139 | at TeX's interactive prompt. Then do
140 |
141 | luatex index
142 | makeindex index
143 | bibtex index
144 | luatex index
145 | luatex index
146 |
147 | The multiple runs of TeX are needed to resolve cross-references.
148 |
149 | === TeXs other than LuaTeX
150 |
151 | If you're using a TeX other than LuaTeX (e.g., XeTeX), use
152 | `--shell-escape` so that MetaPost can be called on one of the
153 | illustrations. The first TeX run may fail due to missing files.
154 | Type `s` at the TeX prompt to force XeTeX to continue.
155 |
156 | If the MetaPost executable is named `mp` on your system (e.g.,
157 | MiKTeX), you may need to create an `mpost` batch file that calls
158 | `mp`. If the shell escape doesn't work on your TeX for some
159 | reason, explicitly call
160 |
161 | mpost lambda
162 | epstopdf lambda-1.eps
163 |
164 | after the first TeX run.
165 |
166 | === HTML documentation
167 |
168 | To get an HTML version of the document, run
169 |
170 | tex2page index
171 |
172 | a few times. Since `.tex2page.hdir` is set to `docs`, the HTML is
173 | created in the `docs` subdirectory. (This also serves as a check
174 | that TeX2page is indeed correctly installed on your machine.)
175 |
176 | As with TeX, multiple runs of `tex2page` are needed to resolve
177 | cross-references, but each run of `tex2page` will explicitly tell
178 | you if another run is necessary.
179 |
180 | The WWW copy of the HTML documentation is at
181 | http://ds26gte.github.io/tex2page/index.html.
182 |
183 | // Last modified 2022-07-04
184 |
--------------------------------------------------------------------------------
/tex2pagedeprecated.tex:
--------------------------------------------------------------------------------
1 | % last change 2018-06-14
2 |
3 | \let\maybeendinput\relax
4 | \ifx\shipout\UnDeFiNeD
5 | \let\maybeendinput\endinput
6 | \fi\maybeendinput
7 |
8 | \input plainsection
9 | \input defun
10 |
11 | \edef\atcatcodebeforetexzpage{%
12 | \noexpand\catcode`\noexpand\@=\the\catcode`\@}
13 | \catcode`\@11
14 |
15 |
16 | %
17 |
18 | \csname plaintextweaks\endcsname
19 |
20 | %
21 |
22 | \def\emph{\bgroup\it
23 | \ifmmode\else\aftergroup\italiccorrection\fi
24 | \let\dummy=}
25 |
26 | \def\begin#1{\begingroup
27 | \def\end##1{\csname end#1\endcsname\endgroup}%
28 | \csname #1\endcsname}
29 |
30 | %\def\hr{\smallskip\line{\leaders\hbox{~.~}\hfill}\smallskip}
31 |
32 | %
33 |
34 | % don't let caps disable end-of-sentence spacing -- assumes we won't use
35 | % dots after caps for abbrevs
36 |
37 | \def\nocapdot{%
38 | \count255=`\A
39 | \loop
40 | \sfcode\the\count255=1000
41 | \ifnum\count255<`\Z
42 | \advance\count255 by 1
43 | \repeat
44 | }
45 |
46 | % " --> `` or ''
47 |
48 | \def\smartdoublequotes{%
49 | \defcsactive\"{\futurelet\smartdoublequotesI
50 | \smartdoublequotesII}%
51 | \def\smartdoublequotesII{%
52 | \ifcat\noexpand\smartdoublequotesI a``\else
53 | \if\noexpand\smartdoublequotesI 0``\else
54 | \if\noexpand\smartdoublequotesI 1``\else
55 | \if\noexpand\smartdoublequotesI 2``\else
56 | \if\noexpand\smartdoublequotesI 3``\else
57 | \if\noexpand\smartdoublequotesI 4``\else
58 | \if\noexpand\smartdoublequotesI 5``\else
59 | \if\noexpand\smartdoublequotesI 6``\else
60 | \if\noexpand\smartdoublequotesI 7``\else
61 | \if\noexpand\smartdoublequotesI 8``\else
62 | \if\noexpand\smartdoublequotesI 9``\else
63 | ''\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}%
64 | }
65 |
66 | %
67 |
68 | \def\emailliketext{\nocapdot\smartdoublequotes}
69 |
70 | %
71 |
72 | \def\gobbleencl{\bgroup
73 | \def\do##1{\catcode`##1=12 }\dospecials
74 | \catcode`\{1 \catcode`\}2 \catcode`\^^M=9
75 | \futurelet\gobbleenclQnext\gobbleenclQii}
76 |
77 | \def\gobbleenclQii{\ifx\gobbleenclQnext\bgroup
78 | \let\gobbleenclQnext\gobblegroupQii
79 | \else\let\gobbleenclQnext\gobbleenclQiii\fi
80 | \gobbleenclQnext}
81 |
82 | \def\gobbleenclQiii#1{%
83 | \def\gobbleenclQiv##1#1{\egroup}%
84 | \gobbleenclQiv}
85 |
86 | %
87 |
88 | \let\strike\fiverm % can be much better!
89 | %
90 |
91 | % \packindex declares that subitems be bundled into one
92 | % semicolon-separated paragraph
93 |
94 | \def\packindex{%
95 | \def\theindex{\begingroup
96 | \parskip0pt \parindent0pt
97 | \def\item{\par\hangindent20pt \hangafter1 }%
98 | \def\subitem{\unskip; }%
99 | \def\subsubitem{\unskip; }%
100 | \def\see{\bgroup\it see \aftergroup\gobblegroup\let\dummy=}%
101 | \let\indexspace\medskip}}
102 |
103 | % Use \printindex instead of \inputindex if you want
104 | % the section heading ``Index'' automatically generated.
105 |
106 | \def\printindex{\csname beginsection\endcsname Index\par
107 | \inputindex}
108 |
109 | \ifx\pdfoutput\UnDeFiNeD\else
110 | %but remember to \input epsf or supp-pdf as appropriate
111 | \def\epsfbox#1{\convertMPtoPDF{#1}{1}{1}}%
112 | \fi
113 |
114 | \def\r#1{{\accent23 #1}}
115 |
116 | \def\verbc{\begingroup
117 | \verbsetup\afterassignment\verbcI
118 | \let\verbcII=}
119 |
120 | \def\verbcI{{\verbfont\verbcII}\endgroup}
121 |
122 | \let\E\verbc
123 |
124 | % The current font is cmtt iff fontdimen3 = 0 _and_
125 | % fontdimen7 != 0
126 |
127 | \def\noncmttQspecific{\let\noncmttQspecificQdoit y%
128 | \ifdim\the\fontdimen3\the\font=0.0pt
129 | \ifdim\the\fontdimen7\the\font=0.0pt
130 | \let\noncmttQspecificQdoit n\fi\fi
131 | \ifx\noncmttQspecificQdoit y%
132 | \defcsactive\<{\relax\char`\<}%
133 | \defcsactive\>{\relax\char`\>}%
134 | \defcsactive\-{\variablelengthhyphen}%
135 | \fi}
136 |
137 | % In a nonmonospaced font, - followed by a letter
138 | % is a regular hyphen. Followed by anything else, it is a
139 | % typewriter hyphen.
140 |
141 | \def\variablelengthhyphen{\futurelet\variablelengthhyphenI
142 | \variablelengthhyphenII}
143 |
144 | \def\variablelengthhyphenII{\ifcat\noexpand\variablelengthhyphenI
145 | a-\else{\tt\char`\-}\fi}
146 |
147 | % uppercase version of \romannumeral
148 |
149 | \def\Romannumeral{\afterassignment\RomannumeralQii\count255=}
150 |
151 | \def\RomannumeralQii{\uppercase\expandafter{\romannumeral\the\count255 }}
152 |
153 | %
154 |
155 | \def\quote{\bgroup\narrower\smallbreak}
156 | \def\endquote{\smallbreak\egroup}
157 |
158 | % \mailto{ADDRESS} becomes
159 | % ADDRESS in HTML, and
160 | % ADDRESS in DVI.
161 |
162 | \let\mailto\url
163 |
164 | %
165 |
166 | \ifx\bull\UnDeFiNeD
167 | % from manmac
168 | \def\bull{\vrule height .9ex width .8ex depth -.1ex } % square bullet
169 | \fi
170 |
171 |
172 | %\def\rawhtml{\errmessage{Can't occur outside
173 | % \string\htmlonly}}
174 | %\def\endrawhtml{\errmessage{Can't occur outside
175 | % \string\htmlonly}}
176 |
177 | \let\rawhtml\iffalse
178 | \let\endrawhtml\fi
179 |
180 | \let\htmlheadonly\iffalse
181 | \let\endhtmlheadonly\fi
182 |
183 | \let\cssblock\iffalse
184 | \let\endcssblock\fi
185 |
186 | \def\inputcss#1 {\relax}
187 | \let\htmladdimg\gobblegroup
188 |
189 | \def\htmlref{\bgroup\aftergroup\gobblegroup\let\dummy=}
190 |
191 | %
192 |
193 | \let\htmlcolophon\gobblegroup
194 | \let\htmldoctype\gobblegroup
195 | \let\htmlmathstyle\gobblegroup
196 |
197 | \let\slatexlikecomments\relax
198 | \let\noslatexlikecomments\relax
199 |
200 | \let\imgpreamble\iffalse
201 | \let\endimgpreamble\fi
202 |
203 | \def\inputexternallabels#1 {\relax}
204 | \def\includeexternallabels#1 {\relax}
205 |
206 | \let\evalh\gobblegroup
207 | \let\evalq\gobblegroup
208 |
209 | \ifx\TZPcommonlisp\UnDeFiNeD
210 | \let\TZPcommonlisp=0
211 | \fi
212 |
213 | \let\htmlpagebreak\relax
214 |
215 | \let\htmlpagelabel\gobblegroup
216 |
217 | \def\htmlpageref{\errmessage{Can't occur except inside
218 | \string\htmlonly}}
219 |
220 | % Miscellaneous stuff
221 |
222 | %\def\hr{$$\hbox{---}$$}
223 | \def\hr{\medbreak\centerline{---}\medbreak}
224 | %\def\hr{\par\centerline{$*$}\par}
225 |
226 | \let\htmlimageformat\gobblegroup
227 | \let\htmlimageconversionprogram\gobblegroup
228 |
229 | \let\externaltitle\gobblegroup
230 | \let\ignorenextinputtimestamp\relax
231 |
232 | %
233 |
234 | \let\htmladvancedentities\relax
235 | \let\n\noindent
236 | \let\f\numberedfootnote
237 | \let\scmp\scm
238 | \let\numfootnote\numberedfootnote
239 | \let\writetotoc\writenumberedtocline
240 | \let\tag\xrtag
241 | \let\scmfilename\verbwritefile
242 | \let\scmwrite\verbwrite
243 |
244 | %
245 |
246 | \atcatcodebeforetexzpage
247 |
248 | % end of file
249 |
--------------------------------------------------------------------------------
/configure:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Last modified: 2022-07-04
4 |
5 | # Set scmxlate to the pathname of scmxlate/scmxlate.scm
6 | # on your system, if you know it. Otherwise let
7 | # this script figure it out.
8 |
9 | scmxlate=
10 |
11 | # Modify searchpathforscmxlate if you think a
12 | # different set of directories should be
13 | # searched for scmxlate/scmxlate.scm.
14 |
15 | searchpathforscmxlate=".. ../.. ../../.. $HOME /usr/local /opt"
16 |
17 | findscmxlate() {
18 | test "$scmxlate" && return
19 | echo Trying to find scmxlate/scmxlate.scm on your machine.
20 | echo This may take a while.
21 | for f in $searchpathforscmxlate
22 | do
23 | scmxlate=`find $f -name scmxlate.scm -print|sed 1q`
24 | if test "$scmxlate"
25 | then echo Found $scmxlate
26 | return
27 | fi
28 | #test "$scmxlate" && return
29 | done
30 | echo Couldn\'t find scmxlate/scmxlate.scm on your machine.
31 | echo Trying to get it off the Internet.
32 | git clone https://github.com/ds26gte/scmxlate
33 | scmxlate=scmxlate/scmxlate.scm
34 |
35 | test "$scmxlate" && return
36 | echo Unable to get scmxlate off the Internet.
37 | echo scmxlate is available at
38 | echo https://github.com/ds26gte/scmxlate
39 | echo You may want to get and install scmxlate manually,
40 | echo then try configure again.
41 | exit
42 | }
43 |
44 | adieu() {
45 | if test -f my-tex2page
46 | then
47 | mv my-tex2page tex2page
48 | chmod +x tex2page
49 | echo tex2page has been successfully configured for $dialect.
50 | echo You may put it in your PATH.
51 | else
52 | echo configure "$@" failed!
53 | fi
54 | }
55 |
56 | makeit() {
57 | case "$dialect" in
58 | abcl|allegro|clasp|clisp|clozure|cmucl|ecl|mkcl|sbcl|sbcl-compiled)
59 | :;;
60 | #bigloo|chez|chibi|chicken|gambit|gauche|guile|mitscheme|petite|plt|scm|sxm)
61 | chez|chicken|gambit|gauche|guile|petite|plt)
62 | findscmxlate;;
63 | *)
64 | echo Dialect $dialect not supported!
65 | exit;;
66 | esac
67 | #echo Ignore questions on console.
68 | case "$dialect" in
69 | sbcl-compiled)
70 | sbcl --eval '(require :sb-executable)' \
71 | --eval '(sb-executable:make-executable "my-tex2page"
72 | (list (compile-file "tex2page.lisp")))' \
73 | --eval '(sb-ext:quit)'
74 | rm tex2page.fasl;;
75 |
76 | abcl|allegro|clasp|clisp|clozure|cmucl|ecl|mkcl|sbcl)
77 | echo \":\"\; export LISP=$dialect > my-tex2page
78 | cat tex2page.lisp >> my-tex2page;;
79 |
80 | bigloo)
81 | echo bigloo|bigloo -eval '(load "'$scmxlate'")';;
82 |
83 | chez)
84 | echo chez|scheme $scmxlate;;
85 |
86 | chibi)
87 | echo chibi|chibi-scheme -e '(load "$scmxlate")';;
88 |
89 | chicken)
90 | echo chicken|csi $scmxlate;;
91 |
92 | gambit)
93 | echo gambit|gsi $scmxlate;;
94 |
95 | gauche)
96 | echo gauche|gosh -l $scmxlate;;
97 |
98 | guile)
99 | echo guile|guile -l $scmxlate;;
100 |
101 | mitscheme)
102 | echo mitscheme|scheme -load $scmxlate;;
103 |
104 | petite)
105 | echo petite|petite $scmxlate;;
106 |
107 | plt)
108 | echo If you are not a PLT developer, you probably shouldn\'t
109 | echo be needing to do this.
110 | echo plt|racket -f $scmxlate;;
111 |
112 | scm)
113 | echo scm|scm -f $scmxlate;;
114 |
115 | scsh)
116 | echo scsh|scsh -s $scmxlate;;
117 |
118 | sxm)
119 | echo sxm|sxi $scmxlate;;
120 |
121 | *)
122 | echo This had better be 0xdeadc0de.
123 | exit;;
124 | esac
125 | }
126 |
127 | echodialectsuggestions() {
128 | test "`which abcl 2>/dev/null|grep -v ' '`" &&\
129 | abclpresent=yes
130 | test "`which scheme 2>/dev/null|grep -v ' '`" &&\
131 | chezpresent=yes
132 | test "`which clasp 2>/dev/null|grep -v ' '`" &&\
133 | clasppresent=yes
134 | test "`which clisp 2>/dev/null|grep -v ' '`" &&\
135 | clisppresent=yes
136 | test "`which csi 2>/dev/null|grep -v ' '`" &&\
137 | chickenpresent=yes
138 | test "`which ccl 2>/dev/null|grep -v ' '`" &&\
139 | clozurepresent=yes
140 | test "`which lisp 2>/dev/null|grep -v ' '`" &&\
141 | cmuclpresent=yes
142 | test "`which ecl 2>/dev/null|grep -v ' '`" &&\
143 | eclpresent=yes
144 | test "`which gsi 2>/dev/null|grep -v ' '`" &&\
145 | gambitpresent=yes
146 | test "`which gosh 2>/dev/null|grep -v ' '`" &&\
147 | gauchepresent=yes
148 | test "`which guile 2>/dev/null|grep -v ' '`" &&\
149 | guilepresent=yes
150 | test "`which mkcl 2>/dev/null|grep -v ' '`" &&\
151 | mkclpresent=yes
152 | test "`which petite 2>/dev/null|grep -v ' '`" &&\
153 | petitepresent=yes
154 | test "`which racket 2>/dev/null|grep -v ' '`" &&\
155 | racketpresent=yes
156 | test "`which sbcl 2>/dev/null|grep -v ' '`" &&\
157 | sbclpresent=yes
158 | echo
159 | echo Note: The following look promising on your system:
160 | echo
161 | echo Common Lisps:
162 | echo
163 | test "$abclpresent" &&\
164 | echo \ \ ./configure --dialect=abcl
165 | test "$clasppresent" &&\
166 | echo \ \ ./configure --dialect=clasp
167 | test "$clisppresent" &&\
168 | echo \ \ ./configure --dialect=clisp
169 | test "$clozurepresent" &&\
170 | echo \ \ ./configure --dialect=clozure
171 | test "$cmuclpresent" &&\
172 | echo \ \ ./configure --dialect=cmucl
173 | test "$eclpresent" &&\
174 | echo \ \ ./configure --dialect=ecl
175 | test "$mkclpresent" &&\
176 | echo \ \ ./configure --dialect=mkcl
177 | test "$sbclpresent" &&\
178 | echo \ \ ./configure --dialect=sbcl &&\
179 | echo \ \ ./configure --dialect=sbcl-compiled
180 | echo
181 | echo Schemes:
182 | echo
183 | test "$chezpresent" &&\
184 | echo \ \ ./configure --dialect=chez
185 | test "$chickenpresent" &&\
186 | echo \ \ ./configure --dialect=chicken
187 | test "$gambitpresent" &&\
188 | echo \ \ ./configure --dialect=gambit
189 | test "$gauchepresent" &&\
190 | echo \ \ ./configure --dialect=gauche
191 | test "$guilepresent" &&\
192 | echo \ \ ./configure --dialect=guile
193 | test "$petitepresent" &&\
194 | echo \ \ ./configure --dialect=petite
195 | test "$racketpresent" &&\
196 | echo \ \ ./configure --dialect=racket
197 | }
198 |
199 | echohelp() {
200 | echo List of dialects supported:
201 | echo
202 | cat dialects/dialects-supported.scm | grep -v "^ *;"
203 |
204 | echo
205 | echo If your dialect D is listed above, type
206 | echo \ \ ./configure --dialect=D
207 | echodialectsuggestions
208 | exit
209 | }
210 |
211 | rm -f tex2page
212 | rm -f my-tex2page
213 |
214 | if test 1 -eq `echo $1|grep "^--dialect="|sed 1q|wc -l`
215 | then
216 | dialect=`echo $1|sed 's/--dialect=//'`
217 | if test "$dialect" = "racket"
218 | then
219 | cp -p tex2page.rkt my-tex2page
220 | elif test "$dialect" = "guile" -a -f ./dialects/make-guile-version
221 | then
222 | ./dialects/make-guile-version
223 | else
224 | makeit
225 | fi
226 | adieu
227 | else echohelp
228 | fi
229 |
--------------------------------------------------------------------------------
/plainsection.tex:
--------------------------------------------------------------------------------
1 | % plainsection.tex
2 | % Dorai Sitaram
3 | % Last change 2016-12-21
4 |
5 | \let\maybeendinput\relax
6 | \ifx\shipout\UnDeFiNeD
7 | \let\maybeendinput\endinput
8 | \fi\maybeendinput
9 |
10 | \edef\atcatcodebeforeplainsection{%
11 | \noexpand\catcode`\noexpand\@=\the\catcode`\@}
12 | \catcode`\@11
13 |
14 | % Sections
15 |
16 | \def\tracksectionchangeatlevel#1{%
17 | \expandafter\let\expandafter\thiscount
18 | \csname sectionnumber#1\endcsname
19 | \ifx\thiscount\relax
20 | \expandafter\expandafter\csname newcount\endcsname
21 | \csname sectionnumber#1\endcsname
22 | \csname sectionnumber#1\endcsname=0
23 | \fi
24 | \expandafter\advance\csname sectionnumber#1\endcsname by 1
25 | \ifx\doingappendix0%
26 | \edef\@currentlabel{\the\csname sectionnumber1\endcsname}%
27 | \else
28 | \edef\@currentlabel{\appendixchar{\the\csname
29 | sectionnumber1\endcsname}}%
30 | \fi
31 | \count255=0
32 | \loop
33 | \advance\count255 by 1
34 | \ifnum\count255=1
35 | \else\edef\@currentlabel{\@currentlabel.\the\csname
36 | sectionnumber\the\count255\endcsname}%
37 | \fi
38 | \ifnum\count255<#1%
39 | \repeat
40 | \loop
41 | \advance\count255 by 1
42 | \expandafter\let\expandafter\nextcount\csname
43 | sectionnumber\the\count255\endcsname
44 | \ifx\nextcount\relax
45 | \let\continue0%
46 | \else
47 | \csname sectionnumber\the\count255\endcsname=0
48 | \let\continue1\fi
49 | \ifx\continue1%
50 | \repeat}
51 |
52 | \def\appendixchar#1{\ifcase#1\or A\or B\or C\or D\or E\or F\or
53 | G\or H\or I\or J\or K\or L\or M\or N\or O\or P\or Q\or R\or S\or
54 | T\or U\or V\or W\or X\or Y\or Z\else AA\fi}
55 |
56 | \newcount\secnumdepth
57 |
58 | \secnumdepth=3
59 |
60 | \def\sectiond#1{\count255=#1%
61 | \ifx\usingchapters1\advance\count255 by 1 \fi
62 | \edef\sectiondlvl{\the\count255 }%
63 | \futurelet\sectionnextchar\sectiondispatch}
64 |
65 | \def\sectiondispatch{\ifx\sectionnextchar*%
66 | \def\sectioncontinue{\sectionstar{\sectiondlvl}}\else
67 | \ifnum\sectiondlvl>\secnumdepth
68 | \def\sectioncontinue{\sectionhelp{\sectiondlvl}{}}\else
69 | \tracksectionchangeatlevel{\sectiondlvl}%
70 | \def\sectioncontinue{\sectionhelp{\sectiondlvl}%
71 | {\@currentlabel}}\fi\fi
72 | \sectioncontinue}
73 |
74 | \def\sectionstar#1*{\sectionhelp{#1}{}}
75 |
76 | \def\sectionhelp#1#2{%
77 | \edef\sectiondepth{#1}%
78 | \def\sectionnr{#2}%
79 | \immediate\openout\sectionQscratchfileport Z-sec-temp
80 | \begingroup
81 | \def\do##1{\catcode`##1=11 }\dospecials
82 | \catcode`\{=1 \catcode`\}= 2
83 | \sectionheader}
84 |
85 | % Vanilla section-header look -- change this macro for new look
86 |
87 | \def\sectionheader#1{\endgroup
88 | \immediate\write\sectionQscratchfileport {#1}%
89 | \immediate\closeout\sectionQscratchfileport
90 | \vskip -\lastskip
91 | \ifnum\sectiondepth>\tocdepth\else
92 | \writenumberedtocline{\sectiondepth}{\sectionnr}{#1}%
93 | \fi
94 | \vskip1.5\bigskipamount
95 | \goodbreak %???
96 | \noindent
97 | \hbox{\vtop{\pretolerance 10000
98 | \raggedright
99 | \noindent\bf
100 | \ifx\sectionnr\empty\else
101 | \sectionnr\enspace\fi
102 | \input Z-sec-temp }}%
103 | \nobreak
104 | \smallskip
105 | %\noindent
106 | }
107 |
108 | % \edef\temp{\write\tocout{\string\hskip#1\space em\string\relax\space #2%
109 | % \string\vtop{\string\hsize=.7\string\hsize
110 | % \string\noindent\string\raggedright\space #3}\string\par}}\temp
111 |
112 | \def\section{\sectiond1}
113 | \def\subsection{\sectiond2}
114 | \def\subsubsection{\sectiond3}
115 | \def\paragraph{\sectiond4}
116 | \def\subparagraph{\sectiond5}
117 |
118 | \let\usingchapters0
119 |
120 | \def\chapter{\global\let\usingchapters1%
121 | \global\footnotenumber=0
122 | \futurelet\chapternextchar\chapterdispatch}
123 |
124 | \def\chapterdispatch{\ifx\chapternextchar*%
125 | \let\chaptercontinue\chapterstar\else
126 | \tracksectionchangeatlevel{1}%
127 | \def\chaptercontinue{\chapterhelp{\@currentlabel}}\fi
128 | \chaptercontinue}
129 |
130 | \def\chapterstar*{\chapterhelp{}}
131 |
132 | \def\chapterhelp#1{%
133 | % #1=number #2=heading-text
134 | \def\chapternr{#1}%
135 | \immediate\openout\sectionQscratchfileport Z-sec-temp
136 | \begingroup
137 | \def\do##1{\catcode`##1=11 }\dospecials
138 | \catcode`\{=1 \catcode`\}=2
139 | \chapterheader}
140 |
141 | \def\chapterheader#1{\endgroup
142 | \immediate\write\sectionQscratchfileport {#1}%
143 | \immediate\closeout\sectionQscratchfileport
144 | \writenumberedtocline{1}{\chapternr}{#1}%
145 | \vfill\eject
146 | \null\vskip3em
147 | \noindent
148 | \ifx\chapternr\empty\hbox{~}\else
149 | \ifx\doingappendix0%
150 | \hbox{\bf Chapter \chapternr}\else
151 | \hbox{\bf Appendix \chapternr}\fi\fi
152 | \vskip 1em
153 | \noindent
154 | \hbox{\bf\vtop{%\hsize=.7\hsize
155 | \pretolerance 10000
156 | \noindent\raggedright\input Z-sec-temp }}%
157 | \nobreak\vskip3em
158 | %\noindent
159 | }
160 |
161 | \let\doingappendix=0
162 |
163 | \def\appendix{\let\doingappendix=1
164 | \csname sectionnumber1\endcsname=0
165 | \relax}
166 |
167 | % enumerate
168 |
169 | \def\enumerate{\par\begingroup
170 | \advance\@itemdepth by 1
171 | \expandafter\csname newcount\endcsname\enumeratenumber
172 | \enumeratenumber=0
173 | \advance\leftskip\parindent
174 | \smallbreak
175 | \def\item{\smallbreak\noindent
176 | \advance\enumeratenumber by 1
177 | \ifnum\@itemdepth=1
178 | \edef\enumeratemark{\the\enumeratenumber.}\else
179 | \ifnum\@itemdepth=2
180 | \count255=\the\enumeratenumber
181 | \advance\count255 by -1 \advance\count255 by `a
182 | \edef\enumeratemark{(\noexpand\char\the\count255 )}\else
183 | \ifnum\@itemdepth=3
184 | \edef\enumeratemark{\noexpand\romannumeral\the\enumeratenumber.}\else
185 | \ifnum\@itemdepth=4
186 | \count255=\the\enumeratenumber
187 | \advance\count255 by -1 \advance\count255 by `A
188 | \edef\enumeratemark{\noexpand\char\the\count255 .}\else
189 | \edef\enumeratemark{\the\enumeratenumber.}\fi\fi\fi\fi
190 | \edef\@currentlabel{\enumeratemark}% needed?
191 | \llap{\enumeratemark\enspace}\ignorespaces}}
192 |
193 | \def\endenumerate{\smallbreak\smallbreak\endgroup\par}
194 |
195 | % itemize
196 |
197 | \newcount\@itemdepth
198 |
199 | \@itemdepth=0
200 |
201 | \def\labelitemi{$\bullet$}
202 | \def\labelitemii{$-$}
203 | \def\labelitemiii{$\star$}
204 | \def\labelitemiv{$\circ$}
205 |
206 | \def\itemize{\par\begingroup
207 | \ifnum\@itemdepth>3
208 | \message{Too deeply nested.}%
209 | \fi
210 | \advance\@itemdepth by 1
211 | \advance\leftskip\parindent
212 | \smallbreak
213 | \def\item{\smallbreak\noindent
214 | \llap{\csname labelitem\romannumeral
215 | \the\@itemdepth\endcsname\enspace}%
216 | \ignorespaces}}
217 |
218 | \def\enditemize{\smallbreak\smallbreak\endgroup\noindent}
219 |
220 | \atcatcodebeforeplainsection
221 |
222 | % end of file
223 |
--------------------------------------------------------------------------------
/dialects/bigloo-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change: 2017-01-10
2 |
3 | (scmxlate-cond
4 | ((eqv? *operating-system* 'unix)
5 | (scmxlate-insert
6 | (string-append
7 | "\":\";"
8 | "echo '(set-repl-printer! (lambda (x . y) #f)) "
9 | "(define arg-one \"'$1'\")"
10 | "(loadq \"'$0'\")"
11 | "(main (list 1 arg-one))"
12 | "'|bigloo -s; exit\n\n"
13 | ))))
14 |
15 | ;(define arg1 (cadr (command-line)))
16 |
17 | (define *scheme-version*
18 | (string-append "Bigloo " *bigloo-version*))
19 |
20 | ;(define *scheme-version* "Bigloo 2.5b")
21 |
22 | (scmxlate-rename
23 | (current-directory chdir)
24 | (integer->char integer->ucs2)
25 | ; (file-or-directory-modify-seconds file-modification-time)
26 | )
27 |
28 | ;(define current-seconds
29 | ; (lambda () #f))
30 |
31 | (scmxlate-ignore
32 | with-output-to-port)
33 |
34 | (scmxlate-ignore-define
35 | string-index)
36 |
37 | (scmxlate-uncall
38 | require
39 | )
40 |
41 | ;(define get-arg1
42 | ; (lambda ()
43 | ; arg-one))
44 |
45 | (define terror
46 | (lambda (where . args)
47 | (write-log #\newline)
48 | (write-log "! ")
49 | (for-each write-log args)
50 | (write-log #\newline)
51 | (when *current-tex-line-number*
52 | (write-log "l.")
53 | (write-log *current-tex-line-number*)
54 | (write-log #\space))
55 | (error where "" #f)))
56 |
57 | ;(define-macro (unless b . ee)
58 | ; `(if (not ,b) (begin ,@ee)))
59 |
60 | ;(define-macro (when b . ee)
61 | ; `(if ,b (begin ,@ee)))
62 |
63 | (define eof (read (open-input-string "")))
64 |
65 | (define flush-output
66 | (lambda z
67 | ;bigloo's flush-output-port always takes 1 arg
68 | (flush-output-port
69 | (if (null? z) (current-output-port) (car z)))))
70 |
71 | (define andmap
72 | (lambda (f s)
73 | (let loop ((s s))
74 | (if (null? s) #t
75 | (and (f (car s)) (loop (cdr s)))))))
76 |
77 | (define ormap
78 | (lambda (f s)
79 | ;Returns true if f is true of some elt in s
80 | (let loop ((s s))
81 | (if (null? s) #f
82 | (or (f (car s)) (loop (cdr s)))))))
83 |
84 | (define-macro (fluid-let xvxv . ee)
85 | (let ((xx (map car xvxv))
86 | (vv (map cadr xvxv))
87 | (old-xx (map (lambda (xv)
88 | (string->symbol
89 | (string-append "%__"
90 | (symbol->string (car xv))))) xvxv))
91 | (res '%_*_res))
92 | `(let ,(map (lambda (old-x x) `(,old-x ,x)) old-xx xx)
93 | ,@(map (lambda (x v)
94 | `(set! ,x ,v)) xx vv)
95 | (let ((,res (begin ,@ee)))
96 | ,@(map (lambda (x old-x) `(set! ,x ,old-x)) xx old-xx)
97 | ,res))))
98 |
99 | (define-macro (defstruct s . ff)
100 | (let ((s-s (symbol->string s)) (n (length ff)))
101 | (let* ((n+1 (+ n 1))
102 | (vv (make-vector n+1)))
103 | (let loop ((i 1) (ff ff))
104 | (if (< i n+1)
105 | (let ((f (car ff)))
106 | (vector-set! vv i (if (pair? f) (cadr f) (not 't)))
107 | (loop (+ i 1) (cdr ff)))
108 | 0))
109 | (let* ((ff-without-colons
110 | (map (lambda (f)
111 | (symbol->string (if (pair? f) (car f) f))) ff))
112 | (ff-with-colons
113 | (map string->keyword ff-without-colons)))
114 | `(begin
115 | (define ,(string->symbol (string-append "make-" s-s))
116 | (lambda fvfv
117 | (let ((st (make-vector ,n+1)) (ff ',ff-with-colons))
118 | (vector-set! st 0 ',s)
119 | ,@(let loop ((i 1) (r '()))
120 | (if (>= i n+1) r
121 | (loop (+ i 1)
122 | (cons `(vector-set! st ,i
123 | ,(vector-ref vv i))
124 | r))))
125 | (let loop ((fvfv fvfv))
126 | (if (null? fvfv) 0
127 | (begin
128 | (vector-set! st (+ (list-position (car fvfv) ff) 1)
129 | (cadr fvfv))
130 | (loop (cddr fvfv)))))
131 | st)))
132 | ,@(let loop ((i 1) (procs '()))
133 | (if (>= i n+1) procs
134 | (loop (+ i 1)
135 | (let* ((f-s (list-ref ff-without-colons (- i 1))))
136 | (cons
137 | `(define ,(string->symbol
138 | (string-append s-s "-" f-s))
139 | (lambda (x) (vector-ref x ,i)))
140 | (cons
141 | `(define ,(string->symbol
142 | (string-append
143 | "set!" s-s "-" f-s))
144 | (lambda (x v) (vector-set! x ,i v)))
145 | procs))))))
146 | (define ,(string->symbol (string-append s-s "?"))
147 | (lambda (x)
148 | (and (vector? x) (eq? (vector-ref x 0) ',s)))))))))
149 |
150 | #|
151 | (define-macro defstruct
152 | (lambda (s . ff)
153 | (let ((s-s (symbol->string s)) (n (length ff)))
154 | (let* ((n+1 (+ n 1))
155 | (vv (make-vector n+1)))
156 | (let loop ((i 1) (ff ff))
157 | (unless (>= i n+1)
158 | (let ((f (car ff)))
159 | (vector-set! vv i (if (pair? f) (cadr f) '(if #f #f)))
160 | (loop (+ i 1) (cdr ff)))))
161 | (let ((ff (map (lambda (f) (if (pair? f) (car f) f)) ff)))
162 | `(begin
163 | (define ,(string->symbol (string-append "MAKE-" s-s))
164 | (lambda fvfv
165 | (let ((st (make-vector ,n+1)) (ff ',ff))
166 | (vector-set! st 0 ',s)
167 | ,@(let loop ((i 1) (r '()))
168 | (if (>= i n+1) r
169 | (loop (+ i 1)
170 | (cons `(vector-set! st ,i ,(vector-ref vv i))
171 | r))))
172 | (let loop ((fvfv fvfv))
173 | (unless (null? fvfv)
174 | (vector-set! st (+ (list-index ff (car fvfv)) 1) (cadr fvfv))
175 | (loop (cddr fvfv))))
176 | st)))
177 | ,@(let loop ((i 1) (procs '()))
178 | (if (>= i n+1) procs
179 | (loop (+ i 1)
180 | (let ((f (symbol->string (list-ref ff (- i 1)))))
181 | (cons
182 | `(define ,(string->symbol (string-append s-s "." f))
183 | (lambda (x) (vector-ref x ,i)))
184 | (cons
185 | `(define ,(string->symbol (string-append "SET!" s-s "." f))
186 | (lambda (x v) (vector-set! x ,i v)))
187 | procs))))))
188 | (define ,(string->symbol (string-append s-s "?"))
189 | (lambda (x)
190 | (and (vector? x) (eq? (vector-ref x 0) ',s))))))))))
191 | |#
192 |
193 | ;(scmxlate-include "seconds-to-date.scm")
194 |
195 | (define set-start-time
196 | (lambda ()
197 | (let* ((dt (string-downcase (date)))
198 | (re (pregexp
199 | (string-append
200 | "([a-z]+) ([a-z]+) ([0-9]+) "
201 | "([0-9]+):([0-9]+):([0-9]+) ([0-9]+)")))
202 | (mo (string->symbol (pregexp-replace re dt "\\2")))
203 | (dy (string->number (pregexp-replace re dt "\\3")))
204 | (hr (string->number (pregexp-replace re dt "\\4")))
205 | (mi (string->number (pregexp-replace re dt "\\5")))
206 | (yr (string->number (pregexp-replace re dt "\\7"))))
207 | (set! mo
208 | (cdr (assv mo
209 | '((jan . 1) (feb . 2) (mar . 3) (apr . 4)
210 | (may . 5) (jun . 6) (jul . 7) (aug . 8)
211 | (sep . 9) (oct . 10) (nov . 11) (dec . 12)))))
212 | (tex-def-count "\\time" (+ (* 60 hr) mi) #t)
213 | (tex-def-count "\\day" dy #t)
214 | (tex-def-count "\\month" mo #t)
215 | (tex-def-count "\\year" yr #t))))
216 |
--------------------------------------------------------------------------------
/t2p-example/r7rs.t2p:
--------------------------------------------------------------------------------
1 | % r7rs.t2p
2 | % tex2page macro file for r7rs.tex
3 | % Dorai Sitaram
4 | % 18 Dec 2022
5 | % last change 2022-12-29
6 |
7 | \evalh{(!definitely-latex)}
8 |
9 | \let\TZPmathtext 1
10 | \let\TZPcolophondisablecredit 1
11 |
12 | \externaltitle{Revised^7 Report on the Algorithmic Language Scheme}
13 |
14 | % \title{Revised$^7$ Report on the Algorithmic Language Scheme}
15 |
16 | \def\bibname{References}
17 |
18 | \date{}
19 |
20 | \leftdisplays
21 |
22 | \TIIPobeyspacestrictly=1
23 |
24 | \let\TIIPbrORIG\TIIPbr
25 |
26 | \newcount\obeylinesstart
27 |
28 | \def\TIIPbr{\obeylinesstart=0\TIIPbrORIG}
29 |
30 | \let\indexORIG\index
31 |
32 | \let\theindexORIG\theindex
33 | \let\endtheindexORIG\endtheindex
34 |
35 | \ifx\TZPcommonlisp 1
36 | \evalh{
37 | (defun index-massage (s)
38 | (let ((i (- (length s) 1)) (r '()))
39 | (loop
40 | (when (< i 0) (return (concatenate 'string r)))
41 | (let ((c (char s i)))
42 | (decf i)
43 | (case c
44 | ((#\@ #\!) (push c r) (push #\" r))
45 | (t (push c r)))))))
46 | }
47 | \else
48 | \evalh{
49 | (define index-massage
50 | (lambda (s)
51 | (let loop ((i (- (string-length s) 1)) (r '()))
52 | (if (< i 0) (list->string r)
53 | (let ((c (string-ref s i)))
54 | (loop (- i 1)
55 | (case c
56 | ((#\@ #\!) (cons #\" (cons c r)))
57 | (else (cons c r)))))))))
58 | }
59 | \fi
60 |
61 | \def\sqrt#1{(#1)^{1/2}}
62 |
63 | \def\linebreak{\evalh{(get-bracketed-text-if-any)}}
64 |
65 | \def\:{ }
66 |
67 | \let\scriptstyle\relax
68 | \let\small\relax
69 |
70 | \def\cal#1{\csname cal#1\endcsname}
71 |
72 | \let\thebibliographyORIG\thebibliography
73 |
74 | \def\thebibliography#1{\thebibliographyORIG{#1}%
75 | \addcontentsline{toc}{chapter}{\bibname}}
76 |
77 | \let\endthebibliographyORIG\endthebibliography
78 |
79 | \def\endthebibliography{\endthebibliographyORIG
80 | %index
81 | \extrapart{Alphabetic index of definitions of concepts,
82 | keywords, and procedures}%
83 | \gdef\input##1{\let\theindex\theindexORIG
84 | \let\endtheindex\endtheindexORIG
85 | \inputindex
86 | \let\endtheindex\relax
87 | }}
88 |
89 | \let\tabularORIG\tabular
90 |
91 | \def\tabular{%
92 | \let\tabularNext\tabularORIG
93 | \ifnum\sectiondnumber{0}=7
94 | \let\tabularNext\IMGtabular
95 | \fi
96 | \tabularNext}
97 |
98 | \let\setbox\TIIPcomment
99 |
100 | \let\indexORIG\index
101 |
102 | \let\tableofcontentsORIG\tableofcontents
103 |
104 | \ifx\TZPcommonlisp 1 \then
105 | \def\tableofcontents{%
106 | \evalh{(setq *tex-format* ':tex)}%
107 | \tableofcontentsORIG
108 | \evalh{(setq *tex-format* ':latex)}}
109 | \else
110 | \def\tableofcontents{%
111 | \evalh{(set! *tex-format* ':tex)}%
112 | \tableofcontentsORIG
113 | \evalh{(set! *tex-format* ':latex)}}
114 | \fi
115 |
116 | % the image preamble
117 |
118 | \imgpreamble
119 |
120 | {\catcode`\^^M=13 \gdef\myobeycr{\catcode`\^^M=13 \def^^M{\\}}%
121 | \gdef\restorecr{\catcode`\^^M=5 }}
122 | \newcommand{\meta}[1]{{\noindent\hbox{\rm$\langle$#1$\rangle$}}}
123 | \let\hyper=\meta
124 |
125 | \newenvironment{grammar}{
126 | \def\:{\goesto{}}
127 | \def\|{$\vert$}
128 | \cf \myobeycr
129 | \begin{tabbing}
130 | %\qquad\quad \=
131 | \qquad \= $\vert$ \= \kill
132 | }{\unskip\end{tabbing}}
133 |
134 | \newcommand{\sembrack}[1]{[\![#1]\!]}
135 | \newcommand{\fun}[1]{\hbox{\it #1}}
136 | \newenvironment{semfun}{\begin{tabbing}$}{$\end{tabbing}}
137 | \newcommand\LOC{{\tt{}L}}
138 | \newcommand\NAT{{\tt{}N}}
139 | \newcommand\TRU{{\tt{}T}}
140 | \newcommand\SYM{{\tt{}Q}}
141 | \newcommand\CHR{{\tt{}H}}
142 | \newcommand\NUM{{\tt{}R}}
143 | \newcommand\FUN{{\tt{}F}}
144 | \newcommand\EXP{{\tt{}E}}
145 | \newcommand\STV{{\tt{}E}}
146 | \newcommand\STO{{\tt{}S}}
147 | \newcommand\ENV{{\tt{}U}}
148 | \newcommand\ANS{{\tt{}A}}
149 | \newcommand\ERR{{\tt{}X}}
150 | \newcommand\DP{\tt{P}}
151 | \newcommand\EC{{\tt{}K}}
152 | \newcommand\CC{{\tt{}C}}
153 | \newcommand\MSC{{\tt{}M}}
154 | \newcommand\PAI{\hbox{\EXP$_{\rm p}$}}
155 | \newcommand\VEC{\hbox{\EXP$_{\rm v}$}}
156 | \newcommand\STR{\hbox{\EXP$_{\rm s}$}}
157 |
158 | \newcommand\elt{\downarrow}
159 | \newcommand\drop{\dagger}
160 |
161 | \def\P{\hbox{\rm P}}
162 | \def\I{\hbox{\rm I}}
163 | \def\Ksem{\hbox{$\cal K$}}
164 | \def\Esem{\hbox{$\cal E$}}
165 |
166 | \def\K{\hbox{\rm K}}
167 | \def\I{\hbox{\rm I}}
168 | \def\E{\hbox{\rm E}}
169 | \def\C{\hbox{$\Gamma$}}
170 | \def\Con{\hbox{\rm Con}}
171 | \def\Ide{\hbox{\rm Ide}}
172 | \def\Exp{\hbox{\rm Exp}}
173 | \def\Com{\hbox{\rm Com}}
174 | \def\|{$\vert$}
175 |
176 | \def\Ksem{\hbox{$\cal K$}}
177 | \def\Esem{\hbox{$\cal E$}}
178 | \def\Csem{\hbox{$\cal C$}}
179 |
180 | \newcommand{\wrong}[1]{\fun{wrong }\hbox{\rm``#1''}}
181 | \newcommand{\go}[1]{\hbox{\hspace*{#1em}}}
182 |
183 | \newcommand{\arbno}[1]{#1\hbox{\rm*}}
184 | \newcommand{\atleastone}[1]{#1\hbox{$^+$}}
185 | \newcommand{\goesto}{$\longrightarrow$}
186 |
187 | \newcommand{\sharpfoo}[1]{{\tt\##1}}
188 | \newcommand{\schfalse}{\sharpfoo{f}}
189 | \newcommand{\schtrue}{\sharpfoo{t}}
190 |
191 | \def\sharpindex#1{}
192 |
193 | \newcommand{\singlequote}{{\tt'}} %\char19
194 | \newcommand{\doublequote}{{\tt"}}
195 | \newcommand{\backquote}{{\tt\char18}}
196 | \newcommand{\backwhack}{{\tt\char`\\}}
197 | \newcommand{\atsign}{{\tt\char`\@}}
198 | \newcommand{\sharpsign}{{\tt\#}}
199 | \newcommand{\verticalbar}{{\tt|}}
200 |
201 | \newcommand{\ide}[1]{{\frenchspacing\tt{#1}}}
202 | \def\elem{\hbox{\raise.13ex\hbox{$\scriptstyle\in$}}}
203 | \let\cf\tt
204 |
205 | \newcommand{\dotsfoo}{$\ldots\,$}
206 |
207 | \setbox0=\hbox{\tt\Exp{} \goesto{}} %\tt for spacing
208 | \setbox1=\hbox to 1\wd0{\hfil \|}
209 |
210 | \def\todo#1{}
211 |
212 | \let\latexdocument\document
213 | \def\document{\latexdocument\Large}
214 |
215 | \endimgpreamble
216 |
217 | \let\documentORIG\document
218 |
219 | % post preamble
220 |
221 | \def\document{\documentORIG
222 |
223 | \TIIPobeyspacestrictly=0
224 |
225 | \def\semfun{\TIIPlatexenvasimage{semfun}}
226 |
227 | \renewenvironment{grammar}{%
228 | %\def\>{\qquad}%
229 | \def\>{\ifnum\obeylinesstart=0\qquad\obeylinesstart=1\else~~~\fi}%
230 | \def\:{\goesto{}}%
231 | \def\|{$\vert$}%
232 | \def\={}%
233 | \TIIPobeylinestrictly=1%
234 | \cf\obeylines}{}
235 |
236 | \let\grammarORIG\grammar
237 |
238 | \def\grammar{%
239 | \let\grammarNext\grammarORIG
240 | \ifnum\sectiondnumber{0}=7
241 | \ifnum\sectiondnumber{1}>1
242 | \def\grammarNext{\TIIPlatexenvasimage{grammar}}\fi\fi
243 | \grammarNext}
244 |
245 | \newcommand\topnewpage[0][xyz]{#1}
246 |
247 | % kludge for \copy0 in sec 2.3
248 |
249 | \def\copy0{\verb+[ ] { } |+}
250 |
251 | \let\ide\texttt
252 |
253 | \let\PRIMeject\eject
254 |
255 | \let\eject\relax
256 |
257 | \newcount\clearchapterstarcount
258 |
259 | \def\clearchapterstar{
260 | \global\advance\clearchapterstarcount by 1
261 | \ifnum\clearchapterstarcount=2
262 | \let\Next\gobblegroup
263 | \else
264 | \def\Next{\chapter*}\fi
265 | \Next}
266 |
267 | \def\backquote{{\tt`}}
268 |
269 | \def\hyper##1{<##1>}
270 |
271 | \renewenvironment{entry}[1]{\par##1}{\par}
272 |
273 | \def\pproto##1##2{\leftline{\underline{##2:}\enspace{\tt{}##1}}}
274 |
275 | \def\proto##1##2##3{\pproto{(\mainschindex{##1}##1{\it{}##2\/})}{##3}}
276 | \def\rproto##1##2##3{\proto{##1}{##2}{##3}}
277 |
278 | \renewenvironment{scheme}{\def\ev{\qquad\evalsto}%
279 | \TIIPobeyspacestrictly=1 %
280 | \def\lev{\break\qquad\qquad\evalsto}%
281 | \def\unspecified{{\it{}unspecified}}%
282 | \def\scherror{{\it{}error}}%
283 | \begingroup\tt\obeywhitespace}{\endgroup\par}
284 |
285 | \renewenvironment{schemenoindent}{\def\ev{\qquad\evalsto}%
286 | \TIIPobeyspacestrictly=1 %
287 | \def\lev{\par~~\evalsto}%
288 | \def\unspecified{{\it{}unspecified}}%
289 | \def\scherror{{\it{}error}}%
290 | \tt\obeywhitespace}{}
291 |
292 | \let\dotsfoo\dots
293 |
294 | \let\cf\tt
295 |
296 | \renewenvironment{rationale}{\begin{quotation}{\em Rationale:\enspace}}%
297 | {\end{quotation}}
298 |
299 | \renewenvironment{note}{\begin{quotation}{\em Note:\enspace}}%
300 | {\end{quotation}}
301 |
302 | \def\meta##1{<##1>}
303 |
304 | \let\hyper\meta
305 |
306 | \let\index\indexORIG
307 |
308 | \def\reallyindex##1##2##3{\indexORIG{##1@\csname##2\endcsname##1}}
309 |
310 | \long\def\theindex##1\bigskip{%
311 | \let\theindex\theindexORIG}
312 |
313 | \def\newenvironment##1##2##3{}
314 |
315 | \newcount\clearpagecount
316 |
317 | \let\clearpageOG\clearpage
318 |
319 | \def\clearpage{%
320 | \global\advance\clearpagecount by 1
321 | \ifnum\clearpagecount=1
322 | \else\clearpageOG
323 | \fi}
324 |
325 | }
326 |
--------------------------------------------------------------------------------
/dialects/cl-tex2page.rkt:
--------------------------------------------------------------------------------
1 | ; last change: 2023-01-01
2 |
3 | ;works with CLISP, Clozure CL, CMU CL, ECL, SBCL; but scmxlate
4 | ;translation to CL is mostly for verification (of scmxlate?) these days.
5 | ;Use handwritten tex2page.lisp in the distribution, which is cleaner
6 | ;and faster
7 |
8 | #+clisp
9 | (scmxlate-insert
10 | "\":\"; exec clisp -q -x '"
11 | "(progn (setq *load-verbose* nil) (defvar arg-one \"'$1'\") (values)) "
12 | "(progn (load \"'$0'\") (values)) "
13 | "(progn (tex2page:tex2page arg-one) (values)) "
14 | "(exit)'"
15 | "
16 | ")
17 |
18 | #+clozure
19 | (scmxlate-insert
20 | "\":\"; exec ccl "
21 | "-e '(defvar arg-one \"'$1'\")' "
22 | "-l $0 "
23 | "-e '(tex2page:tex2page arg-one)' "
24 | "-e '(quit)'"
25 | "
26 | ")
27 |
28 | #+ecl
29 | (scmxlate-insert
30 | "\":\";exec ecl "
31 | "-eval '(defvar arg-one \"'$1'\")' "
32 | "-load $0 "
33 | "-eval '(tex2page:tex2page arg-one)' "
34 | "-eval '(quit)'"
35 | "
36 | ")
37 |
38 | #+mkcl
39 | (scmxlate-insert
40 | "\":\";exec mkcl "
41 | "-eval '(defvar arg-one \"'$1'\")' "
42 | "-load $0 "
43 | "-eval '(tex2page:tex2page arg-one)' "
44 | "-eval '(quit)'"
45 | "
46 | ")
47 |
48 | #+sbcl
49 | (scmxlate-insert
50 | "\":\"; exec sbcl --noinform --noprint "
51 | "--eval '(defvar arg-one \"'$1'\")' "
52 | "--load $0 "
53 | "--eval '(tex2page:tex2page arg-one)' "
54 | "--eval '(quit)'"
55 | "
56 | ")
57 |
58 | #+allegro
59 | (scmxlate-insert
60 | "\":\"; exec lisp -batch "
61 | "-e '(defvar arg-one \"'$1'\")' "
62 | "-L $0 "
63 | "-e '(tex2page:tex2page arg-one)' "
64 | "-e '(exit)'"
65 | "
66 | ")
67 |
68 | #+cmu
69 | (scmxlate-insert
70 | "\":\"; exec lisp -noinit "
71 | "-eval '(defvar arg-one \"'$1'\")' "
72 | "-load $0 "
73 | "-eval '(tex2page:tex2page arg-one)' "
74 | "-eval '(quit)'"
75 | "
76 | ")
77 |
78 | #+abcl
79 | (scmxlate-insert
80 | "\":\"; echo '(load \"'$0'\")(tex2page:tex2page \"'$1'\")' |abcl"
81 | "
82 | ")
83 |
84 | #+cmu-obsolete
85 | (scmxlate-insert
86 | "\":\"; echo '(defvar arg-one \"'$1'\") "
87 | "(load \"'$0'\") (quit)' | "
88 | "exec lisp; exit"
89 | "
90 | ")
91 |
92 | (scmxlate-insert
93 | "
94 | ;Common Lisp version of
95 | ;tex2page
96 | ;Dorai Sitaram
97 | ;For details, see
98 | ;http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html
99 |
100 | ;The code following this is a computer-generated
101 | ;translation of the Scheme file tex2page into
102 | ;Common Lisp.
103 |
104 | ;It may not be very human-readable.
105 |
106 | #+sbcl
107 | (declaim (sb-ext:muffle-conditions style-warning))
108 |
109 | ")
110 |
111 | (scmxlate-ignoredef
112 | decode-universal-time
113 | strftime
114 | subseq
115 | write-to-string
116 | )
117 |
118 | (defpackage :tex2page
119 | (:use :cl
120 | #+clozure :ccl
121 | #+cmu :ext
122 | #+ecl :si
123 | #+mkcl :mkcl
124 | #+sbcl :sb-ext
125 | )
126 | (:export :tex2page))
127 |
128 | (in-package :tex2page)
129 |
130 | (defvar *this-package* *package*)
131 |
132 | (defvar *operating-system*
133 | #+win32 'windows
134 | #-win32 'unix)
135 |
136 | #+(and cmu unix)
137 | (defun system (cmd)
138 | (ext:run-program
139 | "/bin/sh" (list "-c" cmd)))
140 |
141 | #+(and sbcl unix)
142 | (defun system (cmd)
143 | (sb-ext::run-program "sh" (list "-c" cmd) :search t :output t))
144 |
145 | #+(and (or allegro clisp) win32)
146 | (defun system (cmd)
147 | (shell
148 | (concatenate 'string "cmd /c " cmd)))
149 |
150 | #+cmu
151 | (defun getenv (v)
152 | (cdr (assoc (intern v :keyword) ext:*environment-list*)))
153 |
154 | (scmxlate-ignore
155 | ; *operating-system*
156 | ; *shell-cmd-prefix*
157 | *package*
158 | getenv
159 | ;list-position
160 | defstruct
161 | ;string-index
162 | ;string-reverse-index
163 | ; sort!
164 | table
165 | nreverse
166 | nconc
167 | with-output-to-port
168 | main)
169 |
170 | ;(defun seconds->date (s)
171 | ; (multiple-value-list
172 | ; (decode-universal-time s)))
173 |
174 | (defun seconds-to-human-time (s)
175 | (multiple-value-bind (sec m h d mo y dow dst tz)
176 | (decode-universal-time s)
177 | (declare (ignore sec))
178 | (format nil "~a, ~a ~a, ~a, ~a:~a~a ~am ~a ~a"
179 | (svref *week-day-names* (mod (1+ dow) 7))
180 | (svref *short-month-names* (1- mo))
181 | d
182 | y
183 | (let ((h (mod h 12)))
184 | (if (= h 0) 12 h))
185 | (if (< m 10) "0" "")
186 | m
187 | (if (<= 0 h 11) "a" "p")
188 | (format nil "UTC~a~a"
189 | (if (> tz 0) "−" "+")
190 | (abs tz))
191 | (if dst "+1" ""))))
192 |
193 | ;;(defun date-second (v) (elt v 0))
194 | ;(defun date-minute (v) (elt v 1))
195 | ;(defun date-hour (v) (elt v 2))
196 | ;(defun date-day (v) (elt v 3))
197 | ;(defun date-month (v) (elt v 4))
198 | ;(defun date-year (v) (elt v 5))
199 | ;(defun date-week-day (v) (elt v 6))
200 |
201 | (defun set-start-time ()
202 | (multiple-value-bind (s m h d mo y)
203 | (decode-universal-time (get-universal-time) 5) ;don't care about TZ
204 | (declare (ignore s mo))
205 | (tex-def-count "\\time" (+ (* 60 h) m) t)
206 | (tex-def-count "\\day" d t)
207 | (tex-def-count "\\month" m t)
208 | (tex-def-count "\\year" y t)))
209 |
210 | (defun string->number (s &optional (base 10))
211 | (if (position #\: s :test #'char=) nil
212 | (let ((n (let ((*read-base* base)) (read-from-string s nil))))
213 | (if (numberp n) n nil))))
214 |
215 | (defun valid-img-file? (f) nil)
216 |
217 | (defun string-index (s c)
218 | (position c s :test #'char=))
219 |
220 | (defun string-reverse-index (s c)
221 | (position c s :test #'char= :from-end t))
222 |
223 | (scmxlate-rename
224 | (current-seconds #'get-universal-time)
225 | (eof :eof-object)
226 | (file-or-directory-modify-seconds #'file-write-date)
227 | (string-index #'string-index)
228 | (string-reverse-index #'string-reverse-index)
229 | )
230 |
231 | (scmxlate-ignoredef-rename
232 | (*epoch-year* 1900)
233 | (eval1 #'eval)
234 | (list-position #'position)
235 | (*return* #\return)
236 | (string-trim #'string-trim-blanks)
237 | (substring? #'search)
238 | (*tab* #\tab)
239 | (table-for-each #'maphash)
240 | (table-get gethash)
241 | )
242 |
243 | (scmxlate-uncall
244 | trace
245 | require)
246 |
247 | (defun make-table (&rest z)
248 | (if (null z)
249 | (make-hash-table)
250 | (make-hash-table :test 'equal)))
251 |
252 | (defun table-put! (k ht v)
253 | (setf (gethash k ht) v))
254 |
255 |
256 | (setq *print-case* :downcase)
257 |
258 | (setq *load-verbose* nil)
259 |
260 | #+sbcl
261 | (setq *compile-verbose* nil)
262 |
263 | (defvar *common-lisp-version*
264 | (concatenate 'string
265 | (lisp-implementation-type) " "
266 | (lisp-implementation-version)))
267 |
268 | (scmxlate-ignoredef-rename
269 | (*scheme-version* *common-lisp-version*))
270 |
271 | (defun number-to-roman (n &optional upcasep)
272 | (format nil
273 | (if upcasep "~@r" "~(~@r~)") n))
274 |
275 | (defun lassoc (k al equ?)
276 | (assoc k al :test equ?))
277 |
278 | (defun ldelete (y xx equ?)
279 | (remove y xx :test equ?))
280 |
281 | (defun member/string-ci=? (s ss)
282 | (member s ss :test #'string-equal))
283 |
284 | (defun string-trim-blanks (s)
285 | (string-trim '(#\space #\tab #\newline #\return) s))
286 |
287 | #|
288 | (defun terror (where &rest args)
289 | (mapc #'write-log args)
290 | (error "~a" where))
291 | |#
292 |
293 | (defun no-aux-dir? ()
294 | (or (probe-file (make-pathname :name ".no-tex2page-aux-dir"))
295 | (probe-file (make-pathname :name ".no-tex2page-aux"))))
296 |
297 | ;(scmxlate-include "fake-strftime.lsp")
298 |
299 | ;(defun strftime (&rest ee) (apply #'strftime-like ee))
300 |
301 | ;(defvar *tab* #\tab)
302 |
303 | ;(defun get-arg1 ()
304 | ; (and (boundp 'arg-one)
305 | ; (not (string= arg-one ""))
306 | ; arg-one))
307 |
308 | ;kludge to let define and set! work inside \eval
309 | ;regardless of whether CL or Scheme is used
310 |
311 | ;(defmacro define (&rest ee)
312 | ; `(defvar ,@ee))
313 | ;
314 | ;(defmacro set! (&rest ee)
315 | ; `(setq ,@ee))
316 | ;
317 | ;(defun display (&rest ee)
318 | ; (apply #'princ ee))
319 |
320 | (scmxlate-postprocess
321 |
322 | #+(or unix darwin)
323 | (scmxlate-system "chmod +x my-tex2page")
324 |
325 | #+win32
326 | (with-open-file (o "tex2page.bat" :direction :output
327 | :if-exists :supersede)
328 | (format o "@echo off ~%~
329 | if exist c:\\_temp.lsp del c:\\_temp.lsp ~%~
330 | echo (defvar arg1 \"%1\") >> c:\\_temp.lsp ~%~
331 | echo (load \"d:/public_html/tex2page/my-tex2page\") >> c:\\_temp.lsp ~%~
332 | echo (exit) >> c:\\_temp.lsp ~%~
333 | ~%~
334 | clisp -q -i c:\\_temp.lsp ~%"))
335 |
336 | )
337 |
--------------------------------------------------------------------------------
/texi2p.tex:
--------------------------------------------------------------------------------
1 | % texi2p.tex
2 | % Dorai Sitaram
3 |
4 | % last changed 2017-01-13
5 |
6 | % This macro file is loaded by TeX2page when processing Texinfo files. If
7 | % the input document, say jobname.texi, needs additional TeX2page-specific
8 | % macros, you may put them in jobname.t2p (as for input documents in plain
9 | % or LaTeX). If you wish to redefine any of the macros already defined in
10 | % texi2p.tex, you will need to explicitly \input texi2p in
11 | % jobname.t2p, _before_ the redefinitions. Whether or not jobname.t2p
12 | % explicitly \inputs it, texi2p.tex will be loaded by TeX2page only
13 | % once. If jobname.t2p does not exist, or if it does _not_ explicitly
14 | % \input texi2p, jobname.texi will implicitly \input texi2p where it
15 | % tries to \input texinfo.
16 |
17 | \ifx\ifinfo\UnDeFiNeD
18 | \let\endloadingtexiiip\relax
19 | \else
20 | \let\endloadingtexiiip\endinput
21 | \message{texi2p already loaded}
22 | \fi
23 | \endloadingtexiiip
24 |
25 | \evalq{
26 | (setq *tex-format* :texinfo)
27 | (activate-cdef #\newline)
28 | (tex-def-char #\newline '() "\\TIIPnewline" nil)
29 | (set-catcode #\@ 0)
30 | }
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 | \def\contents{\evalh{
56 | (toss-back-string "\\tableofcontents")
57 | (toss-back-string
58 | (if *using-chapters-p*
59 | "\\NONTEXINFOchapter*{Contents}"
60 | "\\NONTEXINFOsection*{Contents}"))
61 | }}
62 |
63 | \def\titlefont#1{{\Huge #1}}
64 |
65 | %\def\titlepage{\let\pageOLD\page
66 | %\TIIPendgraf\begingroup\large
67 | %\def\page{\endgroup\pageOLD\titlepage}}
68 | %
69 | %\let\endtitlepage\endgroup
70 |
71 | \let\titlepage\relax
72 | \let\endtitlepage\relax
73 |
74 | \def\titlepage{\TIIPendgraf\begingroup\large}
75 | \let\endtitlepage\endgroup
76 |
77 | \evalq{(defvar *texinfo-values* '())}
78 |
79 | \def\setQii{\evalq{
80 | (let* ((var (get-peeled-group))
81 | (val (get-peeled-group)))
82 | ;(format t "var= ~s; val= ~s~%" var val)
83 | (push (cons var val) *texinfo-values*)
84 | ;(format t "tvv= ~s~%" *texinfo-values*)
85 | )
86 | }}
87 |
88 | \def\set#1 #2
89 | {\setQii{#1}{#2}}
90 |
91 | \def\value{\evalh{
92 | (let* ((var (get-peeled-group))
93 | (c (assoc var *texinfo-values* :test #'string=)))
94 | ;(format t "var= ~s; c= ~s~%" var c)
95 | (when c (tex2page-string (cdr c))))
96 | }}
97 |
98 | \let\NONTEXINFOend\end
99 |
100 | \def\end #1
101 | {\message{doing end #1}\csname end#1\endcsname}
102 |
103 | \let\group\begingroup
104 |
105 | %\let\NONTEXINFOnode\node
106 |
107 | %\def\node#1
108 | %{\NONTEXINFOnode{#1}}
109 |
110 | \def\ignorespacestillnewlineinclusive{\evalh{
111 | (let (c)
112 | (loop
113 | (setq c (snoop-actual-char))
114 | (when (eq c :eof-object) (return))
115 | (unless (char-whitespace-p c) (return))
116 | (get-actual-char)
117 | (when (char= c #\newline) (return))))
118 | }}
119 |
120 | \def\node{\evalh{
121 | (let (c (r '()))
122 | (loop
123 | (setq c (snoop-actual-char))
124 | (case c
125 | ((#\, #\return #\newline)
126 | (when (char= c #\,) (eat-till-eol))
127 | (setq *recent-node-name*
128 | (concatenate 'string (reverse r)))
129 | (return))
130 | (t (get-actual-char)
131 | (push c r)))))
132 | }}
133 |
134 | \def\anchor#1{\tag{#1}{#1}}
135 |
136 | \def\menu{\iffalse}
137 | \def\endmenu{\fi}
138 |
139 | \def\macro{\iffalse}
140 | \def\endmacro{\fi}
141 |
142 | \def\direntry{\iffalse}
143 | \def\enddirentry{\fi}
144 |
145 | \def\ignore{\iffalse}
146 | \def\endignore{\fi}
147 |
148 | \def\ifplaintext{\iffalse}
149 | \def\endifplaintext{\fi}
150 |
151 | \def\ifxml{\iffalse}
152 | \def\endifxml{\fi}
153 |
154 | \def\ifinfo{\iffalse}
155 | \def\endifinfo{\fi}
156 |
157 | \def\ifdocbook{\iffalse}
158 | \def\endifdocbook{\fi}
159 |
160 | \def\ifnottex{\iffalse}
161 | \def\endifnottex{\fi}
162 |
163 | \def\ifhtml{\iftrue}
164 | \def\endifhtml{\fi}
165 |
166 | \let\html\rawhtml
167 | \let\endhtml\endrawhtml
168 |
169 | %
170 |
171 | \def\uref#1{\urefQii #1,,,\finish}
172 |
173 | \def\urefQii#1,#2,#3,#4\finish{%
174 | \def\urefQiii{#2}%
175 | \ifx\urefQiii\empty\url{#1}%
176 | \else\urlh{#1}{\urefQiii}\fi}
177 |
178 | %
179 |
180 | \let\include\input
181 |
182 | %\verbescapechar\\
183 |
184 | \let\code\verb
185 | \let\key\verb
186 | \let\kbd\verb
187 | \let\samp\verb
188 |
189 | \def\xref{See \S\ref}
190 |
191 | \def\pxref{see \S\ref}
192 |
193 | \let\\\TIIPbackslash
194 |
195 | \let\dfn\textit
196 | \let\file\texttt
197 | \let\cite\textit
198 | \let\b\textbf
199 | \let\var\textit
200 | \let\t\texttt
201 | \let\sc\textsc
202 | \let\email\texttt
203 | \let\r\textrm
204 |
205 | %
206 |
207 | \def\tie{ }
208 |
209 | % index
210 |
211 | \def\cindex#1
212 | {\index{#1}}
213 |
214 | \let\pindex\cindex
215 | %\def\pindex#1
216 | %{\index{#1@{\tt#1}}}
217 |
218 | \let\findex\pindex
219 |
220 | \let\kindex\pindex
221 |
222 | \let\vindex\pindex
223 |
224 | %\let\opindex\index
225 | \let\opindex\pindex
226 |
227 | %\let\cmindex\index
228 | \let\cmindex\pindex
229 |
230 | \let\footnote\numfootnote
231 |
232 | \def\center#1
233 | {\centerline{#1}\TIIPnewline}
234 |
235 | \let\NONTEXINFOitem\item
236 |
237 | \let\TABLEitemstyle\relax
238 |
239 | \def\TABLEitem#1
240 | {\NONTEXINFOitem \TABLEitemstyle{#1}\break}
241 |
242 | \def\table#1
243 | {\begingroup\description
244 | \def\TABLEitemstyle{#1}
245 | \let\item\TABLEitem
246 | \let\itemx\TABLEitem
247 | }
248 |
249 | \def\endtable{\enddescription\endgroup}
250 |
251 | \let\ftable\table
252 | \let\endftable\endtable
253 |
254 | \let\multitable\table
255 | \let\endmultitable\endtable
256 |
257 | \def\sp#1
258 | {\par}
259 |
260 | \let\NONTEXINFOitemize\itemize
261 |
262 | \def\itemize#1
263 | {\NONTEXINFOitemize}
264 |
265 | \def\example{\par\TIIPendgraf\bgroup\tt\obeywhitespace\ignorespacestillnewlineinclusive}
266 |
267 | \def\endexample{\egroup\par}
268 |
269 | % check above and @smallexample
270 |
271 | \let\lisp\example
272 | \let\endlisp\endexample
273 |
274 | \let\NONTEXINFOenumerate\enumerate
275 | \let\NONTEXINFOendenumerate\endenumerate
276 | \def\enumerate#1
277 | {\bgroup\NONTEXINFOenumerate
278 | \let\item\NONTEXINFOitem}
279 |
280 | \def\endenumerate{\NONTEXINFOendenumerate\egroup}
281 |
282 | \def\display{\par\bgroup%
283 | \def\end#1#2
284 | {\enddisplay}\obeywhitespace
285 | }
286 |
287 | \def\enddisplay{\egroup\par}
288 |
289 | %
290 |
291 | \let\NONTEXINFOauthor\author
292 | \let\NONTEXINFOchapter\chapter
293 | \let\NONTEXINFOsection\section
294 | \let\NONTEXINFOsubsection\subsection
295 | \let\NONTEXINFOsubsubsection\subsubsection
296 | \let\NONTEXINFOappendix\appendix
297 |
298 | \let\page\eject
299 |
300 | \let\NONTEXINFOtitle\title
301 |
302 | \def\title#1
303 | {\NONTEXINFOtitle{#1}\hrule}
304 |
305 | \def\subtitle#1
306 | {\rightline{#1}}
307 |
308 | \newcount\authorcalled
309 |
310 | \def\author#1
311 | {\ifnum\authorcalled=0
312 | \bigskip\bigskip\bigskip
313 | \global\authorcalled=1
314 | \plainfootnote{\ }{}
315 | \fi
316 | \leftline{\bf#1}}
317 |
318 | \def\appendix{\NONTEXINFOappendix
319 | \let\NONTEXINFOappendix\relax
320 | \chapter}
321 |
322 | %\def\author#1
323 | %{\NONTEXINFOauthor{#1}}
324 |
325 | \let\top\title
326 |
327 | \def\chapter#1
328 | {\NONTEXINFOchapter{#1}\label{#1}}
329 |
330 | \def\unnumbered#1
331 | {\NONTEXINFOchapter*{#1}}
332 |
333 | \def\section#1
334 | {\NONTEXINFOsection{#1}\label{#1}}
335 |
336 | \def\unnumberedsec#1
337 | {\NONTEXINFOsection*{#1}}
338 |
339 | \def\subsection#1
340 | {\NONTEXINFOsubsection{#1}\label{#1}}
341 |
342 | \def\subsubsection#1
343 | {\NONTEXINFOsubsubsection{#1}\label{#1}}
344 |
345 | \def\appendixsec#1
346 | {\NONTEXINFOappendix\NONTEXINFOsection{#1}\label{#1}}
347 |
348 | \def\appendixsubsec#1
349 | {\NONTEXINFOappendix\NONTEXINFOsubsection{#1}\label{#1}}
350 |
351 | \def\appendixsubsubsec#1
352 | {\NONTEXINFOappendix\NONTEXINFOsubsubsection{#1}\label{#1}}
353 |
354 | \def\chapheading#1{\NONTEXINFOchapter*{#1}}
355 | \def\heading#1{\NONTEXINFOsection*{#1}}
356 | \def\subheading#1
357 | {\NONTEXINFOsubsection*{#1}}
358 | \def\subsubheading#1
359 | {\NONTEXINFOsubsubsection*{#1}}
360 |
361 | %only one index
362 |
363 | \def\printindex#1#2{
364 | \def\printindex##1##2{}
365 | \NONTEXINFOchapter*{Index}
366 | {\let\end\NONTEXINFOend
367 | \inputindex}}
368 |
369 | \def\printindex#1#2{%
370 | \def\printindex##1##2{}%
371 | {\let\end\NONTEXINFOend
372 | \inputindex}}
373 |
374 | % is foll right?
375 |
376 | %\def\iftex{\bgroup
377 | % \def\tex{\fi\iftrue}
378 | % \def\endtex{\fi\iffalse}
379 | % \iffalse}
380 | %\def\endiftex{\fi\egroup}
381 |
382 | \def\iftex{\iftrue}
383 | \def\tex{\iftrue}
384 | \def\endtex{\fi}
385 | \def\endiftex{\fi}
386 |
387 | \let\backslash\\
388 |
--------------------------------------------------------------------------------
/t2p-example/r5rs.t2p:
--------------------------------------------------------------------------------
1 | % r5rs.t2p
2 | % tex2page macro file for r5rs.tex
3 | % Dorai Sitaram
4 | % 20 Feb 2001
5 | % last change 2016-11-07
6 |
7 | \evalh{(!definitely-latex)}
8 |
9 | \externaltitle{Revised^5 Report on the Algorithmic Language Scheme}
10 |
11 | \title{Revised$^5$ Report on the Algorithmic Language Scheme}
12 |
13 | \htmlcolophon{dont-credit-tex2page}
14 |
15 | \def\bibname{References}
16 |
17 | \author{
18 | 20 February 1998\\
19 | \\
20 | Richard Kelsey, William Clinger, and Jonathan Rees ({\it Editors})\\
21 | ~\\
22 | \rawhtml
23 |
24 | | H. Abelson | R. K. Dybvig | C. T. Haynes | G. J. Rozas |
25 | | N. I. Adams IV | D. P. Friedman | E. Kohlbecker | G. L. Steele Jr. |
26 | | D. H. Bartley | R. Halstead | D. Oxley | G. J. Sussman |
27 | | G. Brooks | C. Hanson | K. M. Pitman | M. Wand |
28 |
\endrawhtml\\
29 | {\em Dedicated to the Memory of Robert Hieb}
30 | }
31 |
32 | \date{}
33 |
34 | \htmlmathstyle{no-in-text-image no-display-image}
35 |
36 | \leftdisplays
37 |
38 | \TIIPobeyspacestrictly=1
39 |
40 | \let\TIIPbrORIG\TIIPbr
41 |
42 | \newcount\obeylinesstart
43 |
44 | \def\TIIPbr{\obeylinesstart=0\TIIPbrORIG}
45 |
46 | \let\indexORIG\index
47 |
48 | \let\theindexORIG\theindex
49 | \let\endtheindexORIG\endtheindex
50 |
51 |
52 | \evalh{
53 | (define index-massage
54 | (lambda (s)
55 | (let loop ((i (- (string-length s) 1)) (r '()))
56 | (if (< i 0) (list->string r)
57 | (let ((c (string-ref s i)))
58 | (loop (- i 1)
59 | (case c
60 | ((#\@ #\!) (cons #\" (cons c r)))
61 | (else (cons c r)))))))))
62 | }
63 |
64 |
65 | \def\sqrt#1{(#1)^{1/2}}
66 |
67 | \def\linebreak{\evalh{(get-bracketed-text-if-any)}}
68 |
69 | \def\:{ }
70 |
71 | \let\scriptstyle\relax
72 | \let\small\relax
73 |
74 | \def\cal#1{\csname cal#1\endcsname}
75 |
76 | \let\thebibliographyORIG\thebibliography
77 |
78 | \def\thebibliography#1{\thebibliographyORIG{#1}%
79 | \addcontentsline{toc}{chapter}{\bibname}}
80 |
81 | \let\endthebibliographyORIG\endthebibliography
82 |
83 | \def\endthebibliography{\endthebibliographyORIG
84 | %index
85 | \extrapart{Alphabetic index of definitions of concepts,
86 | keywords, and procedures}%
87 | \gdef\input##1{\let\theindex\theindexORIG
88 | \let\endtheindex\endtheindexORIG
89 | \inputindex
90 | \let\endtheindex\relax
91 | }}
92 |
93 | \let\tabularORIG\tabular
94 |
95 | \def\tabular{%
96 | \let\tabularNext\tabularORIG
97 | \ifnum\sectiondnumber{0}=7
98 | \let\tabularNext\IMGtabular
99 | \fi
100 | \tabularNext}
101 |
102 | \let\setbox\TIIPcomment
103 |
104 | \let\indexORIG\index
105 |
106 | \let\tableofcontentsORIG\tableofcontents
107 |
108 | \def\tableofcontents{%
109 | \evalh{(set! *tex-format* 'tex)}%
110 | \tableofcontentsORIG
111 | \evalh{(set! *tex-format* 'latex)}}
112 |
113 | % the image preamble
114 |
115 | \imgpreamble
116 |
117 | {\catcode`\^^M=13 \gdef\myobeycr{\catcode`\^^M=13 \def^^M{\\}}%
118 | \gdef\restorecr{\catcode`\^^M=5 }}
119 | \newcommand{\meta}[1]{{\noindent\hbox{\rm$\langle$#1$\rangle$}}}
120 | \let\hyper=\meta
121 |
122 | \newenvironment{grammar}{
123 | \def\:{\goesto{}}
124 | \def\|{$\vert$}
125 | \cf \myobeycr
126 | \begin{tabbing}
127 | %\qquad\quad \=
128 | \qquad \= $\vert$ \= \kill
129 | }{\unskip\end{tabbing}}
130 |
131 | \newcommand{\sembrack}[1]{[\![#1]\!]}
132 | \newcommand{\fun}[1]{\hbox{\it #1}}
133 | \newenvironment{semfun}{\begin{tabbing}$}{$\end{tabbing}}
134 | \newcommand\LOC{{\tt{}L}}
135 | \newcommand\NAT{{\tt{}N}}
136 | \newcommand\TRU{{\tt{}T}}
137 | \newcommand\SYM{{\tt{}Q}}
138 | \newcommand\CHR{{\tt{}H}}
139 | \newcommand\NUM{{\tt{}R}}
140 | \newcommand\FUN{{\tt{}F}}
141 | \newcommand\EXP{{\tt{}E}}
142 | \newcommand\STV{{\tt{}E}}
143 | \newcommand\STO{{\tt{}S}}
144 | \newcommand\ENV{{\tt{}U}}
145 | \newcommand\ANS{{\tt{}A}}
146 | \newcommand\ERR{{\tt{}X}}
147 | \newcommand\EC{{\tt{}K}}
148 | \newcommand\CC{{\tt{}C}}
149 | \newcommand\MSC{{\tt{}M}}
150 | \newcommand\PAI{\hbox{\EXP$_{\rm p}$}}
151 | \newcommand\VEC{\hbox{\EXP$_{\rm v}$}}
152 | \newcommand\STR{\hbox{\EXP$_{\rm s}$}}
153 |
154 | \newcommand\elt{\downarrow}
155 | \newcommand\drop{\dagger}
156 |
157 | \def\P{\hbox{\rm P}}
158 | \def\I{\hbox{\rm I}}
159 | \def\Ksem{\hbox{$\cal K$}}
160 | \def\Esem{\hbox{$\cal E$}}
161 |
162 | \def\K{\hbox{\rm K}}
163 | \def\I{\hbox{\rm I}}
164 | \def\E{\hbox{\rm E}}
165 | \def\C{\hbox{$\Gamma$}}
166 | \def\Con{\hbox{\rm Con}}
167 | \def\Ide{\hbox{\rm Ide}}
168 | \def\Exp{\hbox{\rm Exp}}
169 | \def\Com{\hbox{\rm Com}}
170 | \def\|{$\vert$}
171 |
172 | \def\Ksem{\hbox{$\cal K$}}
173 | \def\Esem{\hbox{$\cal E$}}
174 | \def\Csem{\hbox{$\cal C$}}
175 |
176 | \newcommand{\wrong}[1]{\fun{wrong }\hbox{\rm``#1''}}
177 | \newcommand{\go}[1]{\hbox{\hspace*{#1em}}}
178 |
179 | \newcommand{\arbno}[1]{#1\hbox{\rm*}}
180 | \newcommand{\atleastone}[1]{#1\hbox{$^+$}}
181 | \newcommand{\goesto}{$\longrightarrow$}
182 |
183 | \newcommand{\sharpfoo}[1]{{\tt\##1}}
184 | \newcommand{\schfalse}{\sharpfoo{f}}
185 | \newcommand{\schtrue}{\sharpfoo{t}}
186 |
187 | \def\sharpindex#1{}
188 |
189 |
190 | \newcommand{\singlequote}{{\tt'}} %\char19
191 | \newcommand{\doublequote}{{\tt"}}
192 | \newcommand{\backquote}{{\tt\char18}}
193 | \newcommand{\backwhack}{{\tt\char`\\}}
194 | \newcommand{\atsign}{{\tt\char`\@}}
195 | \newcommand{\sharpsign}{{\tt\#}}
196 | \newcommand{\verticalbar}{{\tt|}}
197 |
198 |
199 |
200 | \newcommand{\ide}[1]{{\frenchspacing\tt{#1}}}
201 | \def\elem{\hbox{\raise.13ex\hbox{$\scriptstyle\in$}}}
202 | \let\cf\tt
203 |
204 | \newcommand{\dotsfoo}{$\ldots\,$}
205 |
206 | \setbox0=\hbox{\tt\Exp{} \goesto{}} %\tt for spacing
207 | \setbox1=\hbox to 1\wd0{\hfil \|}
208 |
209 |
210 | \def\todo#1{}
211 |
212 | \let\latexdocument\document
213 | \def\document{\latexdocument\Large}
214 |
215 | \endimgpreamble
216 |
217 | % imgdef's
218 |
219 | \imgdef\vdots{$\vdots$}
220 | \imgdef\sigma{$\sigma$}
221 | \imgdef\pi{$\pi$}
222 | \imgdef\in{$\in$}
223 | \imgdef\calK{$\cal K$}
224 | \imgdef\calE{$\cal E$}
225 | \imgdef\downarrow{$\downarrow$}
226 | \imgdef\neq{$\neq$}
227 |
228 |
229 | \let\chapterORIG\chapter
230 |
231 | \def\chapter{%
232 | \ifnum\sectiondnumber{0}=2
233 | \def\copy0{\verb+[ ] { } |+}
234 | \else\ifnum\sectiondnumber{0}=6
235 | \evalh{(set! *use-image-for-displayed-math-p* #t)}%
236 | \def\copy0{\cf\meta{variable} \goesto{} $\langle$}%
237 | \fi\fi
238 | \chapterORIG}
239 |
240 |
241 | \let\documentORIG\document
242 |
243 | % post preamble
244 |
245 | \def\document{\documentORIG
246 |
247 | \TIIPobeyspacestrictly=0
248 |
249 | \def\semfun{\TIIPlatexenvasimage{semfun}}
250 |
251 | \renewenvironment{grammar}{%
252 | %\def\>{\qquad}%
253 | \def\>{\ifnum\obeylinesstart=0\qquad\obeylinesstart=1\else~~~\fi}%
254 | \def\:{\goesto{}}%
255 | \def\|{$\vert$}%
256 | \def\={}%
257 | \TIIPobeylinestrictly=1%
258 | \cf\obeylines}{}
259 |
260 | \let\grammarORIG\grammar
261 |
262 | \def\grammar{%
263 | \let\grammarNext\grammarORIG
264 | \ifnum\sectiondnumber{0}=7
265 | \ifnum\sectiondnumber{1}>1
266 | \def\grammarNext{\TIIPlatexenvasimage{grammar}}\fi\fi
267 | \grammarNext}
268 |
269 |
270 | \def\topnewpage[{\evalh{
271 | (get-group)
272 | (ignorespaces)
273 | (when (char=? (snoop-actual-char) #\])
274 | (get-actual-char))}}
275 |
276 | \maketitle
277 |
278 | % kludge to swallow ill-located date info
279 |
280 | \def\hfil##1{\gdef\hfil{\qquad\qquad\qquad}}
281 |
282 | % kludge for \copy0 in sec 2.3
283 |
284 | \def\copy0{\verb+[ ] { } |+}
285 |
286 |
287 | \let\ide\texttt % but why?
288 |
289 | \let\PRIMeject\eject
290 |
291 | \let\eject\relax
292 |
293 |
294 | \newcount\clearchapterstarcount
295 |
296 | \def\clearchapterstar{
297 | \global\advance\clearchapterstarcount by 1
298 | \ifnum\clearchapterstarcount=2
299 | \let\Next\gobblegroup
300 | \else
301 | \def\Next{\chapter*}\fi
302 | \Next}
303 |
304 | \def\backquote{{\tt`}}
305 |
306 | \def\hyper##1{<##1>} %but why?
307 |
308 | \renewenvironment{entry}[1]{\par##1}{\par}
309 |
310 | \def\pproto##1##2{\leftline{\underline{##2:}\enspace{\tt{}##1}}}
311 |
312 | \def\proto##1##2##3{\pproto{(\mainschindex{##1}##1{\it{}##2\/})}{##3}}
313 | \def\rproto##1##2##3{\proto{##1}{##2}{##3}}
314 |
315 | \renewenvironment{scheme}{\def\ev{\qquad\evalsto}%
316 | \TIIPobeyspacestrictly=1 %
317 | \def\lev{\break\qquad\qquad\evalsto}%
318 | \def\unspecified{{\it{}unspecified}}%
319 | \def\scherror{{\it{}error}}%
320 | \tt\obeywhitespace}{}
321 |
322 | \renewenvironment{schemenoindent}{\def\ev{\qquad\evalsto}%
323 | \TIIPobeyspacestrictly=1 %
324 | \def\lev{\par~~\evalsto}%
325 | \def\unspecified{{\it{}unspecified}}%
326 | \def\scherror{{\it{}error}}%
327 | \tt\obeywhitespace}{}
328 |
329 | \let\dotsfoo\dots
330 |
331 | \let\cf\tt
332 |
333 | \renewenvironment{rationale}{\begin{quotation}{\em Rationale:\enspace}}%
334 | {\end{quotation}}
335 |
336 | \renewenvironment{note}{\begin{quotation}{\em Note:\enspace}}%
337 | {\end{quotation}}
338 |
339 | \def\meta##1{<##1>}
340 |
341 | \let\hyper\meta
342 |
343 | \let\index\indexORIG
344 |
345 | \def\reallyindex##1##2##3{\indexORIG{##1@\csname##2\endcsname##1}}
346 |
347 | \def\reallyindex{\evalh{
348 | (let* ((entry (index-massage (ungroup (get-group))))
349 | (fontname (ungroup (get-group))))
350 | (get-group) ;{{
351 | (toss-back-char #\})
352 | (toss-back-char #\})
353 | (toss-back-string entry)
354 | (toss-back-char #\space)
355 | (toss-back-string fontname)
356 | (toss-back-char #\\)
357 | (toss-back-char #\{)
358 | (toss-back-char #\@)
359 | (toss-back-string entry)
360 | (toss-back-char #\{) ;}}
361 | (toss-back-string "\\indexORIG"))
362 | }}
363 |
364 |
365 | \long\def\theindex##1\bigskip{%
366 | \let\theindex\theindexORIG}
367 |
368 | \def\newenvironment##1##2##3{}
369 |
370 | }
371 |
--------------------------------------------------------------------------------
/cliiscm-tex2page.lisp:
--------------------------------------------------------------------------------
1 | ;last modified 2023-01-01
2 |
3 | (cliiscm-insert
4 | "#!/usr/bin/env racket
5 |
6 | #lang racket
7 | ")
8 |
9 | (require racket/private/more-scheme)
10 |
11 | ; (require racket/trace)
12 |
13 | (cliiscm-uncall
14 |
15 | defpackage
16 | in-package
17 | tex2page
18 | trace
19 |
20 | )
21 |
22 | (cliiscm-rename
23 |
24 | (*common-lisp-version* *scheme-version*)
25 | (nconc append!)
26 | (nreverse reverse!)
27 | (read-from-string string->number)
28 | (search substring?)
29 | (gethash table-get)
30 | (make-hash-table make-table)
31 | (maphash table-for-each)
32 | (remhash table-rem)
33 |
34 | )
35 |
36 | (cliiscm-defsetf
37 |
38 | (istream*-buffer set!istream*-buffer)
39 | (cdef*-active set!cdef*-active)
40 | (cdef*-argpat set!cdef*-argpat)
41 | (cdef*-catcodes set!cdef*-catcodes)
42 | (cdef*-expansion set!cdef*-expansion)
43 | (cdef*-optarg set!cdef*-optarg)
44 | (counter*-value set!counter*-value)
45 | (ostream*-hbuffer set!ostream*-hbuffer)
46 | (table-get table-put!)
47 | (tdef*-active set!tdef*-active)
48 | (tdef*-argpat set!tdef*-argpat)
49 | (tdef*-catcodes set!tdef*-catcodes)
50 | (tdef*-defer set!tdef*-defer)
51 | (tdef*-expansion set!tdef*-expansion)
52 | (tdef*-optarg set!tdef*-optarg)
53 | (tdef*-prim set!tdef*-prim)
54 | (tdef*-thunk set!tdef*-thunk)
55 | (texframe*-aftergroups set!texframe*-aftergroups)
56 | (texframe*-postludes set!texframe*-postludes)
57 | (texframe*-catcodes set!texframe*-catcodes)
58 |
59 | )
60 |
61 | (define *operating-system*
62 | ;change if you need a better OS identifier
63 | (if (getenv "COMSPEC")
64 | (let ((term (getenv "TERM")))
65 | (if (and (string? term) (string=? term "cygwin"))
66 | ':cygwin ':windows))
67 | ':unix))
68 |
69 | (define *scheme-version*
70 | (string-append "Racket " (version) " " (symbol->string *operating-system*)))
71 |
72 | (define *path-separator*
73 | (if (eqv? *operating-system* ':windows) #\; #\:))
74 |
75 | (define *directory-separator*
76 | (if (eqv? *operating-system* ':windows) "\\" "/"))
77 |
78 | (define *package* false)
79 |
80 | (cliiscm-ignoredef
81 |
82 | *tex2page-file-arg*
83 | close-input-port
84 | close-output-port
85 | list->string
86 | index-of
87 | string->list
88 | string->number
89 | string-append
90 | string-length
91 | system
92 |
93 | )
94 |
95 | (cliiscm-ignoredef-rename
96 |
97 | (char-whitespace-p char-whitespace?)
98 | (string-trim-blanks string-trim)
99 | (retrieve-env getenv)
100 | (system-with-visual system)
101 | (*this-package* false)
102 |
103 | )
104 |
105 | (define-namespace-anchor *tex2page-namespace-anchor*)
106 |
107 | (define *tex2page-namespace* (namespace-anchor->namespace *tex2page-namespace-anchor*))
108 |
109 | (define (eval1 s)
110 | (eval s *tex2page-namespace*))
111 |
112 | (define *epoch-year* 1970)
113 |
114 | ; (define *week-day-names* (vector "Sun" "Mon" "Tues" "Wed" "Thurs" "Fri" "Sat"))
115 |
116 | (define (decode-universal-time s)
117 | (let ((ht (and s (seconds->date s))))
118 | ;s m h d mo y
119 | (cond (ht (list false (date-minute ht) (date-hour ht)
120 | (date-day ht) (date-month ht) (date-year ht)))
121 | (else (list false false false
122 | false false false)))))
123 |
124 | (define (strftime ignore-format d)
125 | (let ((m (date-minute d))
126 | (h (date-hour d))
127 | (dy (date-day d))
128 | (mo (date-month d))
129 | (y (date-year d))
130 | (dow (date-week-day d))
131 | (tzsec (date-time-zone-offset d)))
132 | (let ((tz (and tzsec (/ tzsec 3600))))
133 | (string-append
134 | (vector-ref *week-day-names* dow)
135 | ", "
136 | (vector-ref *short-month-names* (- mo 1))
137 | " "
138 | (number->string dy)
139 | ", "
140 | (number->string y)
141 | (if tz
142 | (string-append
143 | ", "
144 | (let ((h (modulo h 12)))
145 | (number->string (if (= h 0) 12 h)))
146 | ":"
147 | (if (< m 10) "0" "")
148 | (number->string m)
149 | " "
150 | (if (<= 0 h 11) "a" "p")
151 | "m UTC"
152 | (if (> tz 0) "+" "−")
153 | (number->string (abs tz)))
154 | "")))))
155 |
156 | (define (seconds-to-human-time s)
157 | (strftime "%a, %b %e, %Y, %l:%M %p %Z" (seconds->date s)))
158 |
159 | ;Racket lists are immutable; however, keep these nonlossy names so
160 | ;Schemes where lists are mutable can exploit that fact
161 | (define append! append)
162 | (define reverse! reverse)
163 |
164 | ;(defstruct structname [field | (field default-value)] ...)
165 | ;
166 | ;creates
167 | ;the constructor make-structname
168 | ;the predicate structname?
169 | ;the accessors structname-field (for each field)
170 | ;the setters set!structname-field (for each field)
171 | ;
172 | ;make-structname can take {field init-value} arguments,
173 | ;in which it case it sets field to init-value. Otherwise,
174 | ;it sets field to default-value, if such was provided in
175 | ;the defstruct call
176 |
177 | (defmacro defstruct (s . ff)
178 | (let ((string-to-keyword
179 | (lambda (s)
180 | (if (symbol? ':shibboleth) ;i.e., not STklos
181 | (string->symbol (string-append ":" s))
182 | (string->keyword s))))
183 | (s-s (symbol->string s)) (n (length ff)))
184 | (let* ((n+1 (+ n 1))
185 | (vv (make-vector n+1)))
186 | (let loop ((i 1) (ff ff))
187 | (if (< i n+1)
188 | (let ((f (car ff)))
189 | (vector-set! vv i (and (pair? f) (cadr f)))
190 | (loop (+ i 1) (cdr ff)))
191 | 0))
192 | (let* ((ff-without-colons
193 | (map (lambda (f)
194 | (symbol->string (if (pair? f) (car f) f))) ff))
195 | (ff-with-colons
196 | (map string-to-keyword
197 | ff-without-colons)))
198 | `(begin
199 | (define ,(string->symbol (string-append "make-" s-s))
200 | (lambda fvfv
201 | (let ((st (make-vector ,n+1)) (ff ',ff-with-colons))
202 | (vector-set! st 0 ',s)
203 | ,@(let loop ((i 1) (r '()))
204 | (if (>= i n+1) r
205 | (loop (+ i 1)
206 | (cons `(vector-set! st ,i
207 | ,(vector-ref vv i))
208 | r))))
209 | (let loop ((fvfv fvfv))
210 | (if (null? fvfv) 0
211 | (begin
212 | (vector-set! st (+ (index-of ff (car fvfv)) 1)
213 | (cadr fvfv))
214 | (loop (cddr fvfv)))))
215 | st)))
216 | ,@(let loop ((i 1) (procs '()))
217 | (if (>= i n+1) procs
218 | (loop (+ i 1)
219 | (let* ((f-s (list-ref ff-without-colons (- i 1))))
220 | (cons
221 | `(define ,(string->symbol
222 | (string-append s-s "-" f-s))
223 | (lambda (x) (vector-ref x ,i)))
224 | (cons
225 | `(define ,(string->symbol
226 | (string-append
227 | "set!" s-s "-" f-s))
228 | (lambda (x v) (vector-set! x ,i v)))
229 | procs))))))
230 | (define ,(string->symbol (string-append s-s "?"))
231 | (lambda (x)
232 | (and (vector? x) (eq? (vector-ref x 0) ',s)))))))))
233 |
234 | (defstruct table (test eqv?) (alist '()))
235 |
236 | (define (table-get k tbl . d)
237 | ;(printf "tbl=~s; k=~s; (d)=~s~%" tbl k d)
238 | (cond ((lassoc k (table-alist tbl) (table-test tbl))
239 | => (lambda (c) (vector-ref (cdr c) 0)))
240 | ((pair? d) (car d))
241 | (else false)))
242 |
243 | (define (table-rem k tbl)
244 | (table-put! k tbl false))
245 |
246 | (define (table-put! k tbl v)
247 | (let ((al (table-alist tbl)))
248 | (let ((c (lassoc k al (table-test tbl))))
249 | (if c (vector-set! (cdr c) 0 v)
250 | (set!table-alist tbl (cons (cons k (vector v)) al))))))
251 |
252 | (define (table-for-each p tbl)
253 | (for-each
254 | (lambda (c)
255 | (p (car c) (vector-ref (cdr c) 0)))
256 | (table-alist tbl)))
257 |
258 | (define (substring? s1 s2)
259 | ;if s1 is a substring of s2, returns the index in
260 | ;s2 that s1 starts at. O/w return false.
261 | ;
262 | (let* ((s1-len (string-length s1))
263 | (s2-len (string-length s2))
264 | (n-give-up (+ 1 (- s2-len s1-len))))
265 | (let loop ((i 0))
266 | (if (< i n-give-up)
267 | (let loop2 ((j 0) (k i))
268 | (if (< j s1-len)
269 | (if (char=? (string-ref s1 j) (string-ref s2 k))
270 | (loop2 (+ j 1) (+ k 1))
271 | (loop (+ i 1)))
272 | i))
273 | false))))
274 |
275 | (define (lassoc k al equ?)
276 | ;(printf "doing lassoc k=~s; al=~s; equ?=~s~%" k al equ?)
277 | (let loop ((al al))
278 | (if (null? al) false
279 | (let ((c (car al)))
280 | (if (equ? (car c) k) c
281 | (loop (cdr al)))))))
282 |
283 | (define (rassoc v al)
284 | ;we only use it on alists where the values are eqv-able
285 | (ormap (lambda (c)
286 | (and (eqv? (cdr c) v) c))
287 | al))
288 |
289 | (define (write-to-string n . z)
290 | (if (pair? z) ;i.e. :base 16
291 | (number->string (if (inexact? n) (inexact->exact n) n) 16)
292 | (number->string n)))
293 |
294 | (define (number-to-roman n . upcase?)
295 | ;adapted from CLISP's format impl
296 | (set! upcase? (and (pair? upcase?) (car upcase?)))
297 | ;
298 | (unless (and (integer? n) (>= n 0))
299 | (terror 'number-to-roman "Missing number"))
300 | ;
301 | (let ((roman-digits
302 | ; decimal_value, roman_char, lower_decimal_value_used_to_modify
303 | '((1000 #\m 100) (500 #\d 100) (100 #\c 10) (50 #\l 10)
304 | (10 #\x 1) (5 #\v 1) (1 #\i 0)))
305 | (approp-case (lambda (c)
306 | (if upcase? (char-upcase c) c))))
307 | (let loop ((n n) (dd roman-digits) (s '()))
308 | (if (null? dd)
309 | (if (null? s) "0"
310 | (list->string (reverse s)))
311 | (let* ((d (car dd))
312 | (val (car d))
313 | (char (approp-case (cadr d)))
314 | (nextval (caddr d)))
315 | (let loop2 ((q (quotient n val))
316 | (r (remainder n val))
317 | (s s))
318 | (if (= q 0)
319 | (if (>= r (- val nextval))
320 | (loop (remainder r nextval) (cdr dd)
321 | (cons char
322 | (cons (approp-case (cadr (assv nextval dd)))
323 | s)))
324 | (loop r (cdr dd) s))
325 | (loop2 (- q 1) r (cons char s)))))))))
326 |
327 | (define (string-index s c)
328 | ;returns the leftmost index of s where c occurs
329 | ;
330 | (let ((n (string-length s)))
331 | (let loop ((i 0))
332 | (cond ((>= i n) false)
333 | ((char=? (string-ref s i) c) i)
334 | (else (loop (+ i 1)))))))
335 |
336 | (define (string-reverse-index s c)
337 | ;returns the rightmost index of s where c occurs
338 | ;
339 | (let loop ((i (- (string-length s) 1)))
340 | (cond ((< i 0) false)
341 | ((char=? (string-ref s i) c) i)
342 | (else (loop (- i 1))))))
343 |
344 | (define (string=split s sep)
345 | (let loop ((s s) (r '()))
346 | (let ((i (string-reverse-index s sep)))
347 | (cond (i (loop (substring s 0 i) (cons (substring s (+ i 1)) r)))
348 | (else (cons s r))))))
349 |
350 | (define (read-6hex i)
351 | (let* ((x (read i))
352 | (htmlcolor (string-upcase
353 | (cond ((symbol? x) (symbol->string x))
354 | ((number? x) (number->string x))
355 | (else (terror 'atom-to-6hex "Misformed argument."))))))
356 | (string-append "#" (case (string-length htmlcolor)
357 | ((1) "00000")
358 | ((2) "0000")
359 | ((3) "000")
360 | ((4) "00")
361 | ((5) "0")
362 | (else "")) htmlcolor)))
363 |
364 | (cliiscm-postamble)
365 |
366 | (tex2page
367 | (let ((args (current-command-line-arguments)))
368 | (and (> (vector-length args) 0) (vector-ref args 0))))
369 |
370 | (cliiscm-postprocess
371 | (cliiscm-system "cp my-tex2page.lisp tex2page.rkt")
372 | (cliiscm-system "chmod +x tex2page.rkt")
373 | (cliiscm-system "ln -sf tex2page.rkt tex2page")
374 | (format t "tex2page has been successfully configured for Racket.~%")
375 | (format t "You may put it in your PATH.~%")
376 | )
377 |
--------------------------------------------------------------------------------
/t2p-example/book.t2p:
--------------------------------------------------------------------------------
1 | % book.t2p
2 | % tex2page macro file for book.tex, SICP2e
3 | % Dorai Sitaram
4 | % 30 Jan 2001
5 |
6 | % sicp-css.t2p contains cascading-style info
7 |
8 | \input sicp-css.t2p
9 |
10 | % Don't use images for in-text math
11 |
12 | \nohtmlmathintextimg
13 |
14 | % SICP sets its displayed material flushleft
15 |
16 | \leftdisplays
17 |
18 | % {smallequation}
19 |
20 | \let\smallequation\displaymath
21 | \let\endsmallequation\enddisplaymath
22 |
23 | % \an{metavariable}
24 |
25 | \def\an#1{\mathg{\langle}{\em#1}\mathg{\rangle}}
26 |
27 | % {imgpreamble}
28 | %
29 | % Repeat defns \an, \aal, {smallequation} so
30 | % they can be used by TeX fragments that
31 | % are destined to become images
32 | %
33 | % Redefine \document so that images get enlarged
34 |
35 | \imgpreamble
36 | %\usepackage{times}
37 | %\usepackage{mathptm}
38 | \usepackage{epsf}
39 | \def\epsfsize#1#2{1.3#1}
40 | \def\an#1{$\langle${\em #1}$\rangle$}
41 | \def\aal{\alpha{\raise 1pt\hbox{\hskip -4pt{\char'47}}}}
42 | \let\smallequation\displaymath
43 | \let\endsmallequation\enddisplaymath
44 | \let\ORIGparbox\parbox
45 | \def\KLUDGEDparbox#1{%
46 | \gdef\parbox##1{\ORIGparbox{9em}}%
47 | \ORIGparbox{3em}}
48 | \makeatletter
49 | \def\Stabular{%
50 | \let\parbox\KLUDGEDparbox
51 | \par
52 | \parindent\z@skip
53 | %\small
54 | \addvspace{6\p@}%
55 | \let\@halignto\@empty
56 | \@tabular
57 | }
58 | \makeatother
59 | \let\endStabular\endtabular
60 | \let\ORIGdocument\document
61 | \def\document{\ORIGdocument\Large}
62 | \endimgpreamble
63 |
64 | % Figure and table numbers are prefixed
65 | % with chapter (depth = 0) number
66 |
67 | \evalh{
68 | (set!counter.within (table-get *dotted-counters* "figure") 0)
69 | (set!counter.within (table-get *dotted-counters* "table") 0)
70 | }
71 |
72 | \let\figcaption\caption
73 |
74 | % text uses \center inside figure, but this is
75 | % at odds with overall desire for flushleft displays
76 |
77 | \let\center\leftline
78 |
79 | % Some additional sub-macros used by \maketitle
80 |
81 | \def\edition#1{\def\SAVEedition{#1}}
82 | \def\forewordauthor#1{\def\SAVEforewordauthor{#1}}
83 | \def\publisher#1{\def\SAVEpublisher{#1}}
84 |
85 | % Redefine \maketitle to make use of the above sub-macros
86 |
87 | \def\maketitle{\begingroup
88 | \let\\\break
89 | \rawhtml\endrawhtml
90 | \TIIPtitle
91 | \rawhtml
\endrawhtml
92 | \medskip
93 | \leftline{\SAVEedition}
94 | \bigskip\bigskip
95 | \leftline{\TIIPauthor}
96 | \medskip
97 | \leftline{foreword by \SAVEforewordauthor}
98 | \bigskip\bigskip\bigskip
99 | \leftline{\SAVEpublisher}
100 | \endgroup}
101 |
102 | % Since sicp isn't a standard documentclass, let's
103 | % help tex2page out by telling it that the document
104 | % is book-like, ie, will be using chapters. Saves
105 | % a re-run, perhaps
106 |
107 | \evalh{(set! *using-chapters-p* #t)}
108 |
109 | % Might as well tell it it's LaTeX
110 |
111 | \evalh{(set! *tex-format* 'latex)}
112 |
113 | % Redefine \chapter so that it resets the footnote
114 | % counter
115 |
116 | \let\ORIGchapter\chapter
117 |
118 | \def\chapter{\global\footnotenumber=0
119 | \setcounter{figure}{0}%
120 | \ORIGchapter}
121 |
122 | % Define an {exercise} environment that is numbered
123 | % within chapters
124 |
125 | \newtheorem{exercise}{Exercise}[chapter]
126 |
127 | \let\ORIGexercise\exercise
128 |
129 | \evalh{(define *exercise-labels* '())}
130 |
131 | \def\exercise{\ORIGexercise
132 | \evalh{
133 | (let ((lbl (gen-temp-string)))
134 | (do-label-aux lbl)
135 | (set! *exercise-labels* (cons lbl *exercise-labels*)))
136 | }}
137 |
138 | % \expart
139 |
140 | \def\expart#1{#1.\enspace}
141 |
142 | \def\expartstart{\linebreak\expart}
143 |
144 | % Redefine \section so that it starts a fresh page
145 |
146 | \let\ORIGsection\section
147 |
148 | \def\section{\vfill\eject\ORIGsection}
149 |
150 | % Don't number sections deeper than 3
151 |
152 | \secnumdepth = 3
153 |
154 | % Don't put sections deeper than 2 in ToC
155 |
156 | \tocdepth = 2
157 |
158 | % Heading aliases
159 |
160 | \def\prefacesection{\chapter*}
161 | \def\subheading{\subsubsection*}
162 |
163 | \def\?{-}
164 |
165 | % {epigraph} environment. In-text math is allowed to be imagized
166 | % inside epigraphs, so Heraclitus' quote comes out OK. Use style
167 | % tag "epigraph" so we can change its look via style-sheet
168 |
169 | \def\epigraph{\par\begingroup
170 | \evalh{(set! *use-img-for-in-text-math-p* #t)}
171 | \rawhtml
172 |
173 |
|
174 |
175 | \endrawhtml}
176 |
177 | \def\endepigraph{\rawhtml
178 |
179 | |
180 |
181 | \endrawhtml
182 | \evalh{(set! *use-img-for-in-text-math-p* #f)}
183 | \endgroup\par}
184 |
185 | %
186 |
187 | \def\list#1#2{\begingroup\quotation\let\item\par}
188 | \def\endlist{\endquotation\endgroup}
189 |
190 | \let\bulletlist\itemize
191 | \let\endbulletlist\enditemize
192 |
193 | %\let\Stabular\tabular
194 | \def\Stabular{\TIIPlatexenvasimage{Stabular}}
195 | %\let\Stabular\IMGtabular
196 | %\let\endStabular\endtabular
197 |
198 | % \its slants argument. Used for Scheme output in the {lisp}
199 | % environment
200 |
201 | \let\its\textit
202 |
203 | % Disable kludges; they aren't relevant for HTML
204 |
205 | \def\pagekludge#1{}
206 | \def\linekludge#1{}
207 | \def\shrinksurroundingspace#1{}
208 |
209 | % The calls to \pagebreak aren't relevant for HTML
210 |
211 | \let\pagebreak\relax
212 |
213 | % Let's define select math ctl-seqs as reusable images
214 |
215 | \imgdef\alpha{$\alpha$}
216 | \imgdef\epsilon{$\epsilon$}
217 | \imgdef\Theta{$\Theta$}
218 | \imgdef\theta{$\theta$}
219 | \imgdef\iota{$\iota$}
220 | \imgdef\lambda{$\lambda$}
221 | \imgdef\nu{$\nu$}
222 | \imgdef\tau{$\tau$}
223 | \imgdef\pi{$\pi$}
224 | \imgdef\upsilon{$\upsilon$}
225 | \imgdef\phi{$\phi$}
226 | \imgdef\psi{$\psi$}
227 |
228 | \imgdef\sqrt{$\surd$}
229 | \imgdef\TIIPleftarrow{$\leftarrow$}
230 | \imgdef\TIIPrightarrow{$\rightarrow$}
231 | \imgdef\TIIPuparrow{$\uparrow$}
232 | \imgdef\TIIPmapsto{$\mapsto$}
233 | \imgdef\vdots{$\vdots$}
234 | \imgdef\int{$\int$}
235 |
236 | \def\mapsto{ \TIIPmapsto\ }
237 | \def\leftarrow{ \TIIPleftarrow\ }
238 | \def\rightarrow{ \TIIPrightarrow\ }
239 |
240 | % {lisp} environment encloses Scheme code. The optional
241 | % `*' is irrelevant for HTML, so let's eat it
242 |
243 | \def\lisp{\expandafter\lispII\TIIPeatstar}
244 |
245 | \def\lispII{\par\begingroup\let\aaup\TIIPuparrow\tt\obeywhitespace}
246 |
247 | \def\endlisp{\endgroup\par\TIIPeatstar}
248 |
249 | \let\smalltt\tt
250 |
251 | % \allowbreak seems to cause parskip
252 |
253 | %\let\allowbreak\par
254 |
255 | % \ind \indcode \indprim \indsf \indcodeplus are
256 | % various value-added ways of calling \index
257 |
258 | \evalh{
259 |
260 | ; \ind{entry}[subentry]
261 | ; \indcode{entry}[subentry] ; set in \tt
262 | ; \indprim{entry}[subentry] ; ,, add (primitive procedure)
263 | ; \indsf{entry}[subentry] ; ,, add (special form)
264 | ; \indcodeplus{entry}{...text...}[subentry] ; ,, add ...text...
265 |
266 | (define toss-back-index-text
267 | (lambda (s)
268 | ;escape occurrences of ! within the index argument(s)
269 | (let loop ((i (- (string-length s) 1)))
270 | (unless (< i 0)
271 | (let ((c (string-ref s i)))
272 | (toss-back-char c)
273 | (case c
274 | ((#\!) (toss-back-char #\")))
275 | (loop (- i 1)))))))
276 |
277 | (tex-def-thunk "\\ind"
278 | (lambda ()
279 | (when (char=? (snoop-actual-char) #\*)
280 | (get-actual-char))
281 | (let* ((arg (ungroup (get-group)))
282 | (opt-arg (get-bracketed-text-if-any)))
283 | (toss-back-char #\})
284 | (when opt-arg
285 | (toss-back-index-text opt-arg)
286 | (toss-back-char #\!))
287 | (toss-back-index-text arg)
288 | (toss-back-string "\\index{"))) ;}
289 | *global-texframe*)
290 |
291 | (tex-def-thunk "\\indcode"
292 | (lambda ()
293 | (when (char=? (snoop-actual-char) #\*)
294 | (get-actual-char))
295 | (let* ((arg (ungroup (get-group)))
296 | (opt-arg (get-bracketed-text-if-any)))
297 | (toss-back-char #\})
298 | (when opt-arg
299 | (toss-back-index-text opt-arg)
300 | (toss-back-char #\!))
301 | (toss-back-char #\})
302 | (toss-back-index-text arg)
303 | (toss-back-string "\\tt ")
304 | (toss-back-char #\{)
305 | (toss-back-char #\@)
306 | (toss-back-index-text arg)
307 | (toss-back-char #\{)
308 | (toss-back-string "\\index")))
309 | *global-texframe*)
310 |
311 | (tex-def-thunk "\\indprim"
312 | (lambda ()
313 | (when (char=? (snoop-actual-char) #\*)
314 | (get-actual-char))
315 | (let* ((arg (ungroup (get-group)))
316 | (opt-arg (get-bracketed-text-if-any)))
317 | (toss-back-char #\})
318 | (when opt-arg
319 | (toss-back-index-text opt-arg)
320 | (toss-back-char #\!))
321 | (toss-back-string "(primitive procedure)")
322 | (toss-back-char #\space)
323 | (toss-back-char #\})
324 | (toss-back-index-text arg)
325 | (toss-back-string "\\tt ")
326 | (toss-back-char #\{)
327 | (toss-back-char #\@)
328 | (toss-back-index-text arg)
329 | (toss-back-char #\{)
330 | (toss-back-string "\\index")))
331 | *global-texframe*)
332 |
333 | (tex-def-thunk "\\indsf"
334 | (lambda ()
335 | (when (char=? (snoop-actual-char) #\*)
336 | (get-actual-char))
337 | (let* ((arg (ungroup (get-group)))
338 | (opt-arg (get-bracketed-text-if-any)))
339 | (toss-back-char #\})
340 | (when opt-arg
341 | (toss-back-index-text opt-arg)
342 | (toss-back-char #\!))
343 | (toss-back-string "(special form)")
344 | (toss-back-char #\space)
345 | (toss-back-char #\})
346 | (toss-back-index-text arg)
347 | (toss-back-string "\\tt ")
348 | (toss-back-char #\{)
349 | (toss-back-char #\@)
350 | (toss-back-index-text arg)
351 | (toss-back-char #\{)
352 | (toss-back-string "\\index")))
353 | *global-texframe*)
354 |
355 | (tex-def-thunk "\\indcodeplus"
356 | (lambda ()
357 | (when (char=? (snoop-actual-char) #\*)
358 | (get-actual-char))
359 | (let* ((arg (ungroup (get-group)))
360 | (arg2 (ungroup (get-group)))
361 | (opt-arg (get-bracketed-text-if-any)))
362 | (toss-back-char #\})
363 | (when opt-arg
364 | (toss-back-index-text opt-arg)
365 | (toss-back-char #\!))
366 | (toss-back-index-text arg2)
367 | (toss-back-char #\space)
368 | (toss-back-char #\})
369 | (toss-back-index-text arg)
370 | (toss-back-string "\\tt ")
371 | (toss-back-char #\{)
372 | (toss-back-char #\@)
373 | (toss-back-index-text arg)
374 | (toss-back-char #\{)
375 | (toss-back-string "\\index")))
376 | *global-texframe*)
377 |
378 | ; \indsee{entry}[subentry]{other} ; see other
379 | ; \indseealso{entry}[subentry]{other} ; see also other
380 |
381 | (define def-ind-see
382 | (lambda (see)
383 | (tex-def-thunk (string-append "\\ind" see)
384 | (lambda ()
385 | (let* ((entry (ungroup (get-group)))
386 | (subentry (get-bracketed-text-if-any))
387 | (other (get-group)))
388 | (toss-back-char #\})
389 | (toss-back-index-text other)
390 | (toss-back-string see)
391 | (toss-back-char #\|)
392 | (when subentry
393 | (toss-back-index-text subentry)
394 | (toss-back-char #\!))
395 | (toss-back-string entry)
396 | (toss-back-char #\{)
397 | (toss-back-string "\\index")))
398 | *global-texframe*)))
399 |
400 | (def-ind-see "see")
401 | (def-ind-see "seealso")
402 | }
403 |
404 | % Use the index tex2page generates, not the print-oriented
405 | % index.tex
406 |
407 | \def\listofexercises{
408 | \prefacesection{List of Exercises}
409 | \evalh{
410 | (set! *exercise-labels* (reverse *exercise-labels*))
411 | (for-each
412 | (lambda (lbl)
413 | (do-ref-aux lbl)
414 | (emit "
")
415 | (emit-newline))
416 | *exercise-labels*)
417 | }
418 | %
419 | % following is kludge to force index-inclusion
420 | % the canonical way after list of exercises, instead
421 | % of relying on the hand-tuned job used for the
422 | % print version
423 | %
424 | \input indexcrossrefs
425 | \chapter*{Index}
426 | \begin{epigraph}
427 | Any inaccuracies in this index may be explained by the fact that it
428 | has been prepared with the help of a computer.
429 | \par
430 | \attribution{%$
431 | \ind{Knuth, Donald E.}%
432 | Donald E. Knuth,
433 | {\em Fundamental Algorithms} (Volume 1 of
434 | {\em The Art of\/ Computer Programming})}
435 | \end{epigraph}
436 | \par
437 | \inputindex
438 | \def\input##1{}}
439 |
440 | % cover image
441 |
442 | \centerline{\urlh{#titlepage}{\htmladdimg{cover.jpg}}}
443 |
444 | \vfill\eject
445 |
446 | \tag{titlepage}{-}
447 |
--------------------------------------------------------------------------------