Files
klammertext/sks/kutil/kutil.k
Andy Kopra 61b21d1397 Document language for dates; @eval pathname resolution and :cwd (from dev bc7cd62b6f68)
@date/@datetime gain :lang (German: "16. Juni 1910") over a document-wide
Language state variable, and :number for the numeric form (en 6/16/1910,
de 16.06.1910 per DIN 5008).  @eval finds Python modules next to the file
that names them regardless of the cwd, and the new :cwd option runs an
eval in a chosen working directory (@source_file uses it to resolve
against the document).  Two new test suites ship in tst/.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-27 20:25:49 +02:00

97 lines
3.2 KiB
Plaintext

@@show s : @eval :cpp show show @ @@
@@@argtype caption_side |
the side of its element on which a caption is placed
:pattern top^|right^|bottom^|left
:default bottom
@@@
@@caption_arguments :
:caption
:number.bool true
:caption_side.caption_side
:caption_font.font i
:caption_font_size.float .9
@@
@@reference spec | name :
__REF__*spec*__*name*__
@@
@@@argtype number | a number
:pattern 'float'^|'int'
:python_cast (lambda s: float(s))
@@@
@@@argtype length | a length specifier
#:pattern f^|none^|'float'w^|'float'h^|'int'px^|'float'em^|'int'pt
# The last pattern is a string, used where possible to determine its length
:pattern f^|none^|'float'w^|'float'h^|'int'px^|'float'em^|'int'pt^|"[^^"]+"^|'float'pw^|'float'ph
# :python_cast (lambda s : __import__("kutil").parse_length("tex", s))
@@@
@@@argtype lengths | a list of lengths
:pattern ('length'^|\s+)*
#:python_cast (lambda s : [__import__("kutil").parse_length("tex", e) for e in s.split()])
@@@
@@@argtype element_hpos |
the horizontal position of a block element (a table or an image) within
the text column: center, left, right, or a length, which places the
element's left edge that far from the left margin (e.g. ^:hpos 4em, ^:hpos
.25w). When the element is as wide as the text column, the positions are
indistinguishable.
:pattern center^|left^|right^|'length'
:default center
@@@
@@@argtype figure_id |
an identifier for a figure.
The identifier can be in one of six forms:
before
before <offset-to-figure>
after
after <offset-to-figure>
<image-basename>
<id>
The "before" value means the figure before this place in the text;
the number indicates the number of figures behind that place in the
text. This means that "before" is equivalent to "before 1". The
"after" value uses an offset in the same way but counting forewards.
For images, the <image-basename> argument is the basename argument to
the ^@image klammer and can be used as an identifier.
An <id> is the value of the ^:id argument for an image.
^:pattern before(?^:\s+\d+)?^|after(?^:\s+\d+)?^|[-\w]+
@@@
@@@argtype filename_list |
one or more filenames. Filenames may contain spaces: a list is separated
by a standalone "/" (whitespace on both sides), e.g.
"chapter 1.kt / chapter 2.kt". Without the separator, the names are
separated by whitespace, and names that do not exist are rejoined with
their neighbors into names that do. A leading ~ expands to the home
directory.
:pattern [\s\S]*
:python_cast (lambda s: __import__("kutil").filename_list(s))
@@@
@@@argtype language |
an ISO 639-1 language code (two lowercase letters) selecting the language
of text a klammer generates, e.g. en (English) or de (German). The
languages actually available are listed by the klammer that uses the
argument (^@date and ^@datetime); an unknown code reports them.
:pattern [a-z][a-z]
@@@
# The document-wide language for generated text. A klammer's own :lang
# argument overrides it; see the language argtype above. Consumers today:
# @date and @datetime (month names and date form). Set it for a whole
# document with @@@state Language :value de @@@
@@@state Language :desc Language (ISO 639-1) for generated text :value en @@@