GWEB 0.1.0
GWEB is a literate-programming system for Go, modeled closely on Knuth and
Levy's CWEB: you write one .w file interleaving TeX commentary with Go
code, and two tools turn it into a program or a typeset document.
Highlights
gtangle— extractsgofmt-formatted Go, expanding named sections in
program order; supports@(file@>=multi-file output,@iincludes, and
CWEB-style.chchange files.gweave— typesets a.wfile as a plain-TeX document whose layout
closely matchescweave: run-in bold section headings, bold reserved words and
user types, italic identifiers, real math symbols, a two-column index, a
Names of the Sections list, a contents page, and a running head. Sections (and
code parts) are kept whole on a page.- Hyperlinks & bookmarks — via pdfTeX primitives, or
\special{pdf:…}for the
tex → dvipdfmxroute (\let\pdf+), as in CWEB. - Self-hosting — GWEB is written in itself (
lit/*.w); the committed Go tree
is byte-for-byte reproducible by tangling those sources, and CI enforces the
fixpoint along withgo test,vet, andgofmt. - Examples —
wc,pmap,seq(lazy iterators),floyd(Knuth's toy
partition problem), andsham(a port of Knuth's Stanford GraphBase demo via
go-sgb). - Tooling —
--versionand a cweb-style startup banner, man pages, an
install.sh(commands +gwebmac.tex+ man pages), and a VS Code syntax
highlighter (editors/vscode/).
Install
go install github.com/sjnam/gweb/cmd/gtangle@v0.1.0
go install github.com/sjnam/gweb/cmd/gweave@v0.1.0or, for the full install (commands + gwebmac.tex + man pages), run
./install.sh from a checkout. See the README for usage.