Releases: sjnam/gweb
Release list
GWEB 0.3.2
GWEB 0.3.2 teaches gweave to lay out code by its structure, the way CWEB's
cweave does — the headline change — plus two smaller typesetting refinements
carried over from the 0.3.1 cycle.
Structural indentation (gweave)
gweave used to copy each woven line's indentation straight from the source
whitespace, so carelessly indented source came out just as ragged. It now
derives the indentation from the block structure the way gofmt does — a
running bracket stack — with the special cases a plain brace-counter misses:
switch/selectcase bodies: thecase/defaultlabels stay at the
switch's own level and only the bodies indent;- dedented statement labels (
Loop:) and leading closers (},),]); - a statement continued across a line by a trailing operator (via Go's
automatic-semicolon rule), without double-counting inside brackets; - a block whose opening brace follows a wrapped header — a
funcwhose
signature spanned several lines — so its body lines up under the statement,
not under the wrapped parameters.
Multi-line raw strings and block comments are left verbatim. Horizontal spacing
within a line still follows the source, which for gofmt'd code already encodes
the grammar. The woven output is byte-for-byte identical for every committed web
and bundled example, so well-formatted source is reproduced exactly while sloppy
source is now laid out cleanly — like cweave, which reindents from the C
grammar.
Also in this release
- iota constants set in typewriter. A constant declared in an
iota
enumeration is now typeset in typewriter everywhere it appears, like a@d
macro (and likenil,true,false); a plainconstis left italic. - Qualified format directives.
@s foo.Bar intsets only theBarwritten
asfoo.Bar, leaving an unrelatedabc.Baralone. - Text logos survive in PDF bookmarks, and the Korean
kotexgwebtitle
fonts now use Computer Modern for Latin and Noto only for Hangul.
Full changelog: v0.3.1...v0.3.2
GWEB 0.3.1
GWEB 0.3.1 is a maintenance release: it refines how the literate sources are
organized and fixes two gweave typesetting bugs, with no change to the tangled
or woven output of existing programs beyond the fixes below.
gweave
- Qualified format directives.
@s foo.Bar intnow bolds only theBarthat
is written asfoo.Bar, leaving an unrelatedabc.Baralone; the unqualified
@s Bar intstill bolds everyBar. - Text logos survive in PDF bookmarks. A starred section such as
@* \TEX/ escaping.now shows up as TeX escaping in the outline, instead of
losing the logo and reading/ escaping. The outline title is sanitized the
way CWEB does (cwebman Appendix C).
Literate sources
- The three webs (
common,gtangle,gweave) are restructured into named
sections by concern, with large code parts split so each is about a dozen
lines; multi-line explanatory comments moved into the TeX prose. This changes
only the woven presentation, not the tangled Go.
Full changelog: v0.3.0...v0.3.1
GWEB 0.3.0
GWEB 0.3.0 moves much closer to its model, CWEB, in how it typesets Go, and
restructures the repository down to the essentials — only the Go that bootstraps
gtangle is committed.
CWEB-faithful typesetting (gweave)
Operators and constants now print as CWEB does:
- bitwise xor
^(and^=,&^,&^=) as a circled plus⊕; ==as≡,!=as≠,<=/>=as≤/≥,!as¬,&&/||as∧/∨,
<</>>as≪/≫;- octal literals with a raised circle and oldstyle digits, hexadecimal with a
superscript#, in typewriter; nilasΛ, the way CWEB shows C'sNULL;- a visible space for blanks inside string literals;
- tighter inter-token spacing (
\GS), matching CWEB's math spacing.
In a code comment, a |...| span is now set as inline Go and a \.{...} span as
typewriter, as in CWEB. \datethis (a dated listing) is implemented.
Contents & PDF outline
- A double-star section
@**is a top-level group, its title bold in the
table of contents. - The PDF outline ends with a collapsible “Names of the sections” entry that
lists every section name, each linking to where it is defined — ascweave
does (localized and UTF-16BE-encoded for Korean).
Korean (kotexgweb)
Hangul inside Go strings, @d names, and \.{...} spans is set in a monospace
Hangul; cross-reference notes use the small font, matching the English side.
//line always on, like ctangle
gtangle always emits //line directives (the -line option is gone), so the
Go compiler, go vet, and panic traces report errors at .w positions.
Structure: commit only the bootstrap Go
Following CWEB's tradition, the repository now keeps just the source of truth:
- the tangle and weave engines are folded into their commands — no more
internal/tangleorinternal/weave; each lives in its command’smain
package (GWEB is a set of commands, not a library); - the tests live in the
.wsources (aTestschapter per web), tangled and
git-ignored — no_test.gois committed; - only the Go needed to build
gtanglethe first time is committed;gweaveand
the rest are tangled bymake; - the
lit/directory is gone — each.wsits beside the Go it generates
(internal/web/web.w,cmd/gtangle/gtangle.w,cmd/gweave/gweave.w), with the
mastergweb.wat the repo root.
The self-hosting fixpoint still holds: make bootstrap reproduces the committed
Go byte-for-byte.
Editors
Editor support is now just the VS Code extension; the Emacs and Vim modes are
discontinued (use CWEB's).
GWEB 0.2.0
GWEB 0.2.0 brings Korean literate programming — and, found while writing the
first Korean example, a CWEB-conformance fix for section-name matching.
Korean documentation (new)
Put \input kotexgweb.tex in a .w file's limbo and typeset the woven output
with luatex (not pdftex) to get a fully Korean document — Hangul body,
running heads, contents page, section-name list, and cross-reference notes — with
blue cross-reference links and a Korean PDF outline (bookmark) pane.
tex/kotexgweb.texis one self-contained file: it loads luatexko, sets the
Noto Serif/Sans CJK KR fonts, restates gweave's fixed wording in Korean, and
supplies a LuaTeX PDF back end (gwebmac's links/bookmarks use pdfTeX
primitives luatex lacks). PDF outline titles are emitted as UTF-16BE so Korean
bookmarks render correctly.- The running-head Hangul is set in a sans face to match the small-caps Latin,
and the contents-page title is sized to match English gweb. - Localization is language-agnostic: every fixed string gweave/gwebmac emit
goes through a macro (\GU,\GNused,\Gsectionword,\Gheadfont, …), so
another language needs only its own\inputfile.install.shinstalls
kotexgweb.texnext togwebmac.tex.
Bug fix
- Section-name whitespace. As in CWEB, runs of spaces, tabs, and newlines in
a section name are now collapsed to a single space and trimmed, so a long name
wrapped across lines in one place matches the same name written on one line.
Previously such a reference resolved to section 0 — which also crashed luatex's
PDF backend.
Typesetting refinements (gweave / gwebmac)
constandiotanames are set in typewriter, like CWEB's@dmacros;nil,
true,falseare typewriter (not bold);@dmarks an imported name (e.g.
http.StatusOK) as typewriter.- Type names are set in boldface.
- A narrower, tunable thin space (
\Gthin, 2mu) before(. - TeX is passed through in section names (so
\.{x}works), and@(file@>=
output names are typeset as escaped typewriter paths (underscores, etc.).
New example programs
hangul.w (Korean Fibonacci), pipeline.w (lazy iter.Seq transforms bridged
to a channel fan-out), pairsums.w (max pair-product over subarrays via a Li
Chao tree), squint.w (McIlroy's lazy power series as channel networks),
topswops.w / topswops_fwd.w (Conway's game), and fast_cancel.w.
Tooling & docs
gtangle -version/gweave -versionreport 0.2.0..gitignorecovers CWEB-style aux files (*.idx,*.scn).- VS Code: control codes after leading whitespace are highlighted; VSIX install
is recommended. - README and manual updates.
GWEB 0.1.5
GWEB 0.1.5 — error locations that point back to your .w source.
Highlights
gtangle -line(the headline feature, on by default). The tangled Go now
carries//linedirectives, so the Go compiler,go vet, and panic traces
report errors at.wpositions instead of.goones — the Go counterpart
of CWEB's#line. They survivegofmt(each rides with the code line it
precedes). Pass-line=falseto omit them; GWEB tangles its own sources that
way, keeping the committed Go and the self-hosting fixpoint clean.
Also in this release
- Vim and Emacs syntax highlighting for
.wfiles, alongside the existing
VS Code extension (editors/vim,editors/emacs). - Manual rewritten for readers who already know CWEB, typeset in the format
of Knuth & Levy'scwebman.tex(doc/gwebman.tex,make manual). - CI now lints Markdown (markdownlint), plus a project
.markdownlint.jsonc.
The self-hosting fixpoint (lit/*.w reproduce the committed Go byte-for-byte),
go test, go vet, and gofmt are all green.
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.