Skip to content

GWEB 0.3.2

Latest

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