Skip to content

Commit 2aa6ce5

Browse files
committed
optionally use KaTeX for csug and release_notes
KaTeX renders LaTeX math ahead-of-time to MathML and/or HTML. Its output is accessible to screen readers and other tools (instead of appearing as "<graphic>"), and it also does not suffer from the pixelation of math rendered to GIFs. Also, use scheme.sty and scheme.hsty from stex instead of stale copies with ad-hoc changes. Depends on dybvig/stex#7
1 parent 57f92bb commit 2aa6ce5

13 files changed

+108
-192
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
/xc-*/
2525
/em-*/
2626
*.*run
27+
*.katex-css-link
2728
/csug/math/
2829
/csug/gifs/
30+
/csug/katex/
2931
/csug/Makefile
3032
/csug/*.aux
3133
/csug/*.html
@@ -50,6 +52,7 @@
5052
/csug/primdata.ss
5153
/release_notes/math/
5254
/release_notes/gifs/
55+
/release_notes/katex/
5356
/release_notes/Makefile
5457
/release_notes/*.tex
5558
/release_notes/*.aux

BUILDING

+19-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ The makefile supports several targets:
307307
* `make docs`
308308

309309
Runs the build plus generates HTML and PDF versions of the Chez
310-
Scheme Users Guide and the release notes. Unlike the other build
310+
Scheme User's Guide and the release notes. Unlike the other build
311311
targets, the documentation is not built in the workarea, but rather
312312
in the "csug" and "release_notes" directories (where "configure" is
313313
run).
@@ -320,6 +320,14 @@ The makefile supports several targets:
320320

321321
* ppmtogif and pnmcrop (from Netpbm)
322322

323+
* Optionally, KaTeX (for better math in HTML)
324+
325+
To use KaTeX but not copy the supporting CSS and font files
326+
(e.g. because you wish to link to a copy already installed on your
327+
system), use `make docs KATEX_CSS=no`. See also the documentation
328+
in the "stex/doc" directory for further details and additional
329+
configuration options.
330+
323331
An X11 installation is not required, but ppmtogif does require an
324332
"rgb.txt" file, which it will automatically locate in the common
325333
X11 installation locations. If ppmtogif fails because it cannot
@@ -330,6 +338,16 @@ The makefile supports several targets:
330338
installation, then it might contain an "rgb.txt" in the directory
331339
identified by the `VIMRUNTIME` environment variable.
332340

341+
* `make csug` or `make release_notes`
342+
343+
Like `make docs`, but builds only the Chez Scheme User's Guide or
344+
the release notes, respectively.
345+
346+
* `sudo make install-docs` (or `install-csug` or `install-release_notes`)
347+
348+
Like `make docs` (or `make csug` or `make release_notes`, respectively),
349+
but also installs the built documentation.
350+
333351
* `make clean`
334352

335353
Removes all built elements from the workarea, and then removes

build.zuo

+14-2
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,26 @@
245245
(define name-sym (string->symbol name))
246246
(define (run-make target)
247247
(check-not-kernel-only)
248+
;; Note: build.bat on Windows does not currently configure these
249+
;; settings, so only evaluate (hash-ref config ...) when trying to
250+
;; build a target, not while merely generating the list of targets.
251+
(define install-dir
252+
(hash-ref config install-dir-key))
253+
(define other-install-dir-key
254+
(car (remove install-dir-key doc-install-dir-keys)))
255+
(define other-install-dir
256+
(hash-ref config other-install-dir-key))
248257
(define (->rel-shell pth)
249258
(string->shell (find-relative-path doc-dir pth)))
250259
(shell/wait "make"
251260
(~a "m=" m)
252261
(~a "srcdir=" (->rel-shell (at-source name)))
253-
(~a "installdir="
254-
(->rel-shell (hash-ref config install-dir-key)))
262+
(~a "installdir=" (->rel-shell install-dir))
255263
(~a "STEXLIB=" (->rel-shell stexlib))
264+
(~a other-install-dir-key "=" (->rel-shell other-install-dir))
265+
(~a "rel" other-install-dir-key "="
266+
(string->shell (find-relative-path install-dir
267+
other-install-dir)))
256268
target
257269
(hash 'dir doc-dir)))
258270
`([:target ,mf-out (,mf-in)

csug/csug.css

+2
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ h1, h2, h3, h4 {font-weight: bold}
3333

3434
table.indent {margin-left: 20px}
3535

36+
.schemedisplay { line-height: 1.0625; }
37+
.schemedisplay .katex { font-size: 1em; }

csug/csug.stex

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
% Just don't care about small overflows, most of the time:
5555
\iflatex
56-
\hfuzz=16.0pt
56+
\hfuzz=26.0pt
5757
\fi
5858

5959
\iflatex

csug/csug8.cls

+12-2
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,11 @@
376376
%%% index
377377
\newenvironment{theindex}
378378
{\if@openright\cleardoublepage\else\clearpage\fi
379-
\begingroup\raggedright\schemeindexsize\footnotesize
379+
\begingroup\raggedright\footnotesize
380+
% tighten spacing for entries:
381+
% may need to adjust this for future changes in stex
382+
\def\scheme##1{\mbox{\fontsize{7}{8}\ttfamily\frenchspacing\spaceskip=0.5\fontdimen2\font plus \fontdimen3\font minus 0.5\fontdimen4\font##1}}
383+
\def\var##1{{\footnotesize\textit{##1}}}
380384
\columnseprule \z@
381385
\columnsep 35\p@
382386
\twocolumn[\plainchapterhead{\indexname}]%
@@ -457,6 +461,8 @@
457461
\def\categorymodule{module}
458462
\def\categoryftype{ftype}
459463

464+
%%% summary of forms
465+
% see also summary.stex and summary.ss
460466
\newwrite\forms
461467
\openout\forms=\jobname.rfm
462468
% \formsummary{sort key}{type}{form}{label}
@@ -471,7 +477,11 @@
471477
\hbox to 5pc{#2\ \hfil}%
472478
\hfil #3}}
473479
\newenvironment{thesummary}
474-
{\begingroup\schemesummarysize\small\bigskip
480+
{\begingroup\small\bigskip%
481+
% tighten spacing to fit entries on one line:
482+
% may need to adjust this for future changes in stex
483+
\def\scheme##1{\mbox{\fontsize{8}{9}\ttfamily\frenchspacing\spaceskip=0.5\fontdimen2\font plus \fontdimen3\font minus 0.5\fontdimen4\font##1}}%
484+
\def\var##1{{\footnotesize\textit{##1}}}%
475485
\sfentry{{\slshape Form}}{{\slshape Category}}{{\slshape Page}}
476486
\kern3pt\hrule\kern3pt}
477487
{\endgroup}

csug/scheme.hsty

-33
This file was deleted.

csug/scheme.sty

-89
This file was deleted.

makefiles/Makefile-csug.in

+38-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
srcdir=oops-missing-srcdir
22
installdir=oops-missing-installdir
3+
InstallReleaseNotes=oops-missing-InstallReleaseNotes
4+
relInstallReleaseNotes=oops-missing-relInstallReleaseNotes
35
m=oops-missing-m
46
STEXLIB=oops-missing-stexlib
57
# Zuo overrides the above variables when running `make`
@@ -17,18 +19,6 @@ DIR=$(shell basename `pwd`)
1719

1820
target: canned logcheck1 logcheck2 checklibs $(x).html $(x).pdf
1921

20-
install: target
21-
$(INSTALL) -m 2755 -d $(installdir)
22-
$(INSTALL) -m 0644 --ifdiff *.html *.css $(installdir)
23-
$(INSTALL) -m 0644 --ifdiff csug.pdf $(installdir)/csug10_0.pdf
24-
$(INSTALL) -m 2755 -d $(installdir)/canned
25-
$(INSTALL) -m 0644 --ifdiff canned/* $(installdir)/canned
26-
$(INSTALL) -m 2755 -d $(installdir)/gifs
27-
$(INSTALL) -m 0644 --ifdiff gifs/*.gif $(installdir)/gifs
28-
$(INSTALL) -m 2755 -d $(installdir)/$(mathdir)
29-
$(INSTALL) -m 0644 --ifdiff $(mathdir)/*.gif $(installdir)/$(mathdir)
30-
(cd $(installdir); ln -s -f $(x).html index.html)
31-
3222
# thrice is not enough when starting from scratch
3323
logcheck1: $(x).thirdrun
3424
@if [ -n "`grep 'Warning: Label(s) may have changed' $(x).log`" ] ; then\
@@ -50,14 +40,43 @@ logcheck2: $(x).thirdrun
5040

5141
include $(STEXLIB)/Mf-stex
5242

43+
install: target
44+
$(INSTALL) -m 2755 -d $(installdir)
45+
$(INSTALL) -m 0644 --ifdiff *.html *.css $(installdir)
46+
$(INSTALL) -m 0644 --ifdiff csug.pdf $(installdir)/csug10_0.pdf
47+
$(INSTALL) -m 2755 -d $(installdir)/canned
48+
$(INSTALL) -m 0644 --ifdiff canned/* $(installdir)/canned
49+
$(INSTALL) -m 2755 -d $(installdir)/gifs
50+
$(INSTALL) -m 0644 --ifdiff gifs/*.gif $(installdir)/gifs
51+
ifeq ($(strip $(KATEX)),)
52+
$(INSTALL) -m 2755 -d $(installdir)/$(mathdir)
53+
$(INSTALL) -m 0644 --ifdiff $(mathdir)/*.gif $(installdir)/$(mathdir)
54+
else ifneq ($(strip $(KATEX_CSS)),no)
55+
# if already installed release_notes, share katex.css and fonts
56+
(if $(if $(findstring Windows,$(OS)),[ ! "windows" ],[ -e $(InstallReleaseNotes)/katex/katex.css ] && [ ! -L $(InstallReleaseNotes)/katex ]) ; \
57+
then \
58+
(cd $(installdir); ln -s -f $(relInstallReleaseNotes)/katex katex) ; \
59+
else \
60+
$(INSTALL) -m 2755 -d $(installdir)/katex/fonts ; \
61+
$(INSTALL) -m 0644 --ifdiff katex/katex.css $(installdir)/katex/katex.css ; \
62+
$(INSTALL) -m 0644 --ifdiff katex/fonts/* $(installdir)/katex/fonts ; \
63+
fi)
64+
endif
65+
ifeq ($(OS),Windows_NT)
66+
cp $(installdir)/$(x).html $(installdir)/index.html
67+
else
68+
(cd $(installdir); ln -s -f $(x).html index.html)
69+
endif
70+
71+
5372
stexsrc = csug.stex title.stex copyright.stex contents.stex\
5473
preface.stex intro.stex use.stex expeditor.stex debug.stex foreign.stex\
5574
binding.stex control.stex objects.stex numeric.stex io.stex\
5675
libraries.stex syntax.stex system.stex smgmt.stex threads.stex\
5776
compat.stex bibliography.stex summary.stex
5877
texsrc = ${stexsrc:%.stex=%.tex}
5978

60-
moresrc = tspl4-prep.stex priminfo.ss docond.ss csug8.cls csug8.hcls csug810.clo scheme.sty csug.bib \
79+
moresrc = tspl4-prep.stex priminfo.ss docond.ss csug8.cls csug8.hcls csug810.clo csug.bib \
6180
setup.ss summary.ss tspl.bst
6281

6382
$(stexsrc) $(moresrc):
@@ -136,9 +155,14 @@ $(x).hprethirdrun: $(x).hsecondrun
136155
cat tspl.haux >> $x.haux
137156
touch $(x).hprethirdrun
138157

158+
$(x).hfourthrun: $(x).hprefourthrun
159+
$(x).hprefourthrun: $(x).hthirdrun
160+
cat tspl.haux >> $x.haux
161+
touch $(x).hprefourthrun
162+
139163
$(x).prefirstrun: $(texsrc) csug8.cls csug810.clo
140164

141-
$(x).firstrun: scheme.sty
165+
$(x).firstrun:
142166

143167
tspl.aux: ${TSPLdir}/tspl.aux
144168
cat ${TSPLdir}/*.aux | grep '\\newlabel' | \

makefiles/Makefile-release_notes.in

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
srcdir=oops-missing-srcdir
22
installdir=oops-missing-installdir
3+
InstallCSUG=oops-missing-InstallCSUG
4+
relInstallCSUG=oops-missing-relInstallCSUG
35
m=oops-missing-m
46
STEXLIB=oops-missing-stexlib
57
# Zuo overrides the above variables when running `make`
@@ -25,7 +27,7 @@ bib =
2527
include $(STEXLIB)/Mf-stex
2628

2729
srcs = $(x).stex releasenotes.cls releasenotes.hcls \
28-
macros.stex releasenotes.css scheme.sty
30+
macros.stex releasenotes.css
2931

3032
# define or override suffixes here
3133

@@ -42,10 +44,22 @@ install: $x.pdf $x.html
4244
fi)
4345
$(INSTALL) -m 2755 -d $(installdir)/gifs
4446
$(INSTALL) -m 0644 --ifdiff gifs/*.gif $(installdir)/gifs
45-
$(INSTALL) -m 2755 -d $(installdir)/math
4647
-rm -rf $(installdir)/$(mathdir)
48+
ifeq ($(strip $(KATEX)),)
49+
$(INSTALL) -m 2755 -d $(installdir)/math
4750
$(INSTALL) -m 2755 -d $(installdir)/$(mathdir)
4851
if [ -e $(mathdir)/0.gif ] ; then $(INSTALL) -m 0644 $(mathdir)/*.gif $(installdir)/$(mathdir) ; fi
52+
else ifneq ($(strip $(KATEX_CSS)),no)
53+
# if already installed csug, share katex.css and fonts
54+
(if $(if $(findstring Windows,$(OS)),[ ! "windows" ],[ -e $(InstallCSUG)/katex/katex.css ] && [ ! -L $(InstallCSUG)/katex ]) ; \
55+
then \
56+
(cd $(installdir); ln -s -f $(relInstallCSUG)/katex katex) ; \
57+
else \
58+
$(INSTALL) -m 2755 -d $(installdir)/katex/fonts ; \
59+
$(INSTALL) -m 0644 --ifdiff katex/katex.css $(installdir)/katex/katex.css ; \
60+
$(INSTALL) -m 0644 --ifdiff katex/fonts/* $(installdir)/katex/fonts ; \
61+
fi)
62+
endif
4963

5064
# define any dependencies here
5165

release_notes/releasenotes.css

+2
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,5 @@ table.indent {margin-left: 20px}
5555
.tag{ color: navy; font-weight: bold; }
5656
.entity{ color: purple; font-weight: bold; }
5757
.errflag{ color: red; font-weight: bold; }
58+
.schemedisplay { line-height: 1.0625; }
59+
.schemedisplay .katex { font-size: 1em; }

0 commit comments

Comments
 (0)