Width and height argtypes, kdesc --argtypes from ref/, txt @define/@left_right/@columns, kdiag --check value validation (from dev d6993110e9b3)

Also: the klammertext argtype (descriptions kept as source), txt table
wrapping and :hpos/:offset, @c between ‹ ›, txt section headings, the
ktext newline-only trim, capitalize(), and the argtype test suite.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
ackandClaude Fable 5.1 committed 2026-09-16 16:59:49 +02:00
1 parent 9b0d0d7897
commit 0ead40f272
39 files changed
+734 -158

No files matched your search

+37 -6
View File
@@ -14,6 +14,34 @@
# :python_cast (lambda s : __import__("kutil").parse_length("tex", s))
@@@
# Lengths on an axis (2026-09-16). A width and a height are different
# types so that a value can only name a unit of its own axis: "w" and "pw"
# belong to widths, "h" and "ph" to heights, and a mistake is an argument
# error rather than a silent misreading. A BARE NUMBER is the natural
# unit of the axis in every target -- characters for a width (a column in
# txt, "ch" in html, the width of a digit in tex), lines for a height (a
# newline in txt, "lh" in html, \baselineskip in tex) -- which is what lets
# a klammer written for the page keep its meaning in a terminal. "length"
# stays for the quantities with no axis (a rule thickness).
@@@argtype width |
a horizontal length. A bare number is that many characters (one column
of plain text; in a proportional typeface, the width of a digit, so an
indent or a column lines up across lines even where the letters do not).
Otherwise a number with a unit: ^:width 2em, 12pt, 100px, .5w (that
fraction of the text width), .5pw (of the page width); f or none for an
element's natural width; a quoted string, whose set width is used where
the target can measure it.
:pattern 'float'^|'float'em^|'int'pt^|'int'px^|'float'w^|'float'pw^|f^|none^|"[^^"]+"
@@@
@@@argtype height |
a vertical length. A bare number is that many lines (blank lines in
plain text; the line height of the surrounding text otherwise).
Otherwise a number with a unit: ^:height 2em, 12pt, 100px, .5h (that
fraction of the text height), .5ph (of the page height).
:pattern 'float'^|'float'em^|'int'pt^|'int'px^|'float'h^|'float'ph
@@@
@@@argtype lengths | a list of lengths
:pattern ('length'^|\s+)*
#:python_cast (lambda s : [__import__("kutil").parse_length("tex", e) for e in s.split()])
@@ -37,15 +65,18 @@
An offset has no meaning for a centered element and is ignored there.
Written alone, ^:offset is the standard indentation (e.g. ^:hpos left
^:offset), and a value overrides it (^:hpos right ^:offset 4em).
# A single-purpose type, not a use of "length", because the two values
# A single-purpose type, not a use of "width", because the two values
# below are what the writer relies on and only a type can carry them: an
# element is flush unless an offset is asked for (:default), and asking
# without saying how much is the standard indentation (:alone). A general
# length type must not declare :alone -- a bare option name has to read the
# same way wherever it appears, and "2em" is meaningless for :width.
:pattern 'length'
:default 0pt
:alone 2em
# width type must not declare :alone -- a bare option name has to read the
# same way wherever it appears, and "4" is meaningless for :width.
# Both values are BARE numbers -- characters -- so that they mean the same
# thing under txt as on the page (2026-09-16): four characters is about
# the 2em the alone value used to be, and 0 is flush everywhere.
:pattern 'width'
:default 0
:alone 4
@@@