Skip to content

Releases: sjnam/gweb

GWEB 0.3.2

Choose a tag to compare

@sjnam sjnam released this 04 Jul 09:35

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/select case bodies: the case/default labels 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 func whose
    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 like nil, true, false); a plain const is left italic.
  • Qualified format directives. @s foo.Bar int sets only the Bar written
    as foo.Bar, leaving an unrelated abc.Bar alone.
  • Text logos survive in PDF bookmarks, and the Korean kotexgweb title
    fonts now use Computer Modern for Latin and Noto only for Hangul.

Full changelog: v0.3.1...v0.3.2

GWEB 0.3.1

Choose a tag to compare

@sjnam sjnam released this 02 Jul 10:29

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 int now bolds only the Bar that
    is written as foo.Bar, leaving an unrelated abc.Bar alone; the unqualified
    @s Bar int still bolds every Bar.
  • 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

Choose a tag to compare

@sjnam sjnam released this 30 Jun 12:42

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;
  • nil as Λ, the way CWEB shows C's NULL;
  • 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 — as cweave
    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/tangle or internal/weave; each lives in its command’s main
    package (GWEB is a set of commands, not a library);
  • the tests live in the .w sources (a Tests chapter per web), tangled and
    git-ignored — no _test.go is committed;
  • only the Go needed to build gtangle the first time is committed; gweave and
    the rest are tangled by make;
  • the lit/ directory is gone — each .w sits beside the Go it generates
    (internal/web/web.w, cmd/gtangle/gtangle.w, cmd/gweave/gweave.w), with the
    master gweb.w at 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

Choose a tag to compare

@sjnam sjnam released this 26 Jun 10:56

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.tex is 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 \input file. install.sh installs
    kotexgweb.tex next to gwebmac.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)

  • const and iota names are set in typewriter, like CWEB's @d macros; nil,
    true, false are typewriter (not bold); @d marks 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 -version report 0.2.0.
  • .gitignore covers 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

Choose a tag to compare

@sjnam sjnam released this 22 Jun 13:46

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 //line directives, so the Go compiler, go vet, and panic traces
    report errors at .w positions instead of .go ones — the Go counterpart
    of CWEB's #line. They survive gofmt (each rides with the code line it
    precedes). Pass -line=false to 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 .w files, 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's cwebman.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

Choose a tag to compare

@sjnam sjnam released this 21 Jun 10:38

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 — extracts gofmt-formatted Go, expanding named sections in
    program order; supports @(file@>= multi-file output, @i includes, and
    CWEB-style .ch change files.
  • gweave — typesets a .w file as a plain-TeX document whose layout
    closely matches cweave: 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 → dvipdfmx route (\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 with go test, vet, and gofmt.
  • Exampleswc, pmap, seq (lazy iterators), floyd (Knuth's toy
    partition problem), and sham (a port of Knuth's Stanford GraphBase demo via
    go-sgb).
  • Tooling--version and 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.0

or, for the full install (commands + gwebmac.tex + man pages), run
./install.sh from a checkout. See the README for usage.