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