Files
klammertext/sks/target/target.k
T
ack e4f1307aa9 Characters that killed a render, what may sit next to a klammer, and ref/
A character written in the ^...^ mnemonic form -- ^oe^, ^zz^, ^hello^ --
used to kill ktext outright: no message, no output, and an exit status
that looked like a crash because it was one.  Only the forms that happen
to spell hexadecimal digits escaped, and they were right by luck rather
than by reading.  Any caret form that names no character is now a located
error that quotes what was written.

A klammer may now sit inside square brackets and braces as it already
could inside parentheses, and may be followed by the punctuation that
ends a sentence: [@i word@], {@b word@}, @i word@'s.  The rule is a fixed
list of characters, because none of them can occur inside a klammer name
and so none of them is ambiguous next to a delimiter.  A letter still
cannot: "x@" is the named closing delimiter, so a letter before "@" has
two readings and no rule can separate them.

The abbreviations an author writes -- the hyphen form @i-word, a klammer
glued to its neighbouring punctuation -- are now recognised as author
conveniences only.  They are not applied to @@ definitions or @@@ system
commands, which are written by someone who needs no such shorthand and
whose forms are already whole.

Also fixed, each of them silent: an exported shell function in the
environment broke every @eval in the document; a line break written with
@nl was destroyed when it passed through a klammer that generates a
table, printing as \textbackslash{}newline in the finished PDF; and
"kdesc --coverage" shortened its file column by comparing the spelling of
a path rather than the path, so a klammer set reached by a symbolic link
showed a full path where its neighbours showed a short one.

New in the distribution: ref/, a small klammerset that describes the
Klammermachine's own tables in Klammertext.  It currently provides the
character tables -- the diacritics and the extended Latin letters -- as
klammers that render to any target, so the documentation of what can be
written cannot drift from what the machine accepts.  It is early, and
will grow.

The Klammertext taxonomy now has a section on targets, describes the
@@@klammerset system command alongside the other three, and states the
precedence of "^" -- what a caret means before a letter, a digit, a
punctuation character, and a quote, in one ordered list.

(from dev 6594c7ff8c1f)
2026-09-07 22:37:05 +02:00

109 lines
3.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#[
The targets in the SKS use the LaTeX convention for converting ASCII
characters into standard typographical characters. This is done
by LaTeX by default; other targets must use the transforms parameter
of Parameter_set, as defined for the m_parameters variable of the
Target_registry class. (See file target_registry.cpp.)
The LaTeX transformations supported by the SKS are:
-- -> en-dash
--- -> em-dash
` -> open single quote
' -> close single quote
`` -> open double quote
'' -> close double quote
~ -> non-breaking space
"^" before any punctuation character quotes it (an engine rule, not an SKS
one): the character reaches the output literally, taking no part in the
transforms above -- ^-^- writes two plain hyphens (a --flag in prose), ^~ a
plain tilde. The one exception is the apostrophe: "^" before it opens a
literal span instead (a literal apostrophe is ^0027^), and writing that
pair even in THIS comment would open one -- the span sentinels are placed
before text removal. A target where the raw character would
still be re-interpreted declares its rendering with :resolve -- the tex
target maps a quoted hyphen to {-} (a bare -- in .tex re-forms TeX's dash
ligature) and a quoted tilde to \textasciitilde{} (a raw ~ is TeX's
non-breaking space). Verbatim text (@c, @code, ^'...'^) never needs any
of this: neither the transforms nor the quoting reach it.
]#
@@@state Target_txt_width
:desc Width of the text in the plain text target (txt)
:value 72
@@@
@@@state Target_txt_indent
:desc Width of indentation in the plain text target (txt)
:value 3
@@@
# The txt target is not fully implemented in the SKS yet.
#
# A writer's "~" is a non-breaking space (the LaTeX convention), and it
# becomes the nbsp MARKER here rather than a space directly, for two
# reasons. A transform whose replacement is whitespace is silently
# DISCARDED -- parse_transforms takes the pair with word_split, and a
# space is not a word -- so "~ ^0020^" never did anything, and the
# substitution that made a tilde look like a space lived in the
# justification phase and caught EVERY tilde, so a literal one could not
# be written at all. The marker survives to the phase and becomes a space
# there; a quoted "^~" is a KTESC marker by then, so it is not matched
# here and reaches the reader as a tilde.
# SYNC: phases.txt_nbsp_marker() in sks/target/phases.py.
@@@target txt | Plain text with formatting |
-- - |
--- -- |
`` " |
'' " |
` ` |
' ' |
~ __KTEXTNBSP__
:after_apply
phases.txt_format_footnotes ;
phases.txt_insert_captions ;
phases.txt_justify_blocks
@@@
@@@target html | HTML page
# :escape < &lt; & &amp; |
|
--- &^#x2014; |
-- &^#x2013; |
`` “ |
'' ” |
` ‘ |
' ’ |
~ &^#160;
:after_apply
phases.html_format_footnotes
@@@
# No transforms: LaTeX applies the input conventions itself. The :resolve
# entries say how a QUOTED character renders where the raw character would
# still be re-interpreted by TeX: ^- resolves to {-}, not a bare -, or the
# hyphens re-form a run and the dash ligature turns ^-^- into an en-dash;
# ^~ resolves to \textasciitilde{}, since a raw ~ is TeX's non-breaking
# space. Other quoted punctuation either has an :escape entry (its marker
# takes the escape replacement: ^$ renders as \$) or decodes to the raw
# character.
@@@target tex | LaTeX
:escape \ \textbackslash{} & \& { \{ } \} $ \$ % \% _ \_ ^# \^# ^^ \textasciicircum{}
:resolve - {-} ~ \textasciitilde{}
:after_apply phases.tex_resolve_markers
@@@
@@@target pdf | PDF from LaTeX
:includes tex
# Phases are NOT inherited through :includes -- escapes, transforms and
# resolves are (target_registry.cpp) -- and tex_to_pdf compiles the
# document, so the marker resolution is named here too, and first.
:after_apply
phases.tex_resolve_markers ;
^:cpp *KLAMMERTEXT_HOME*/sks/document/document tex_to_pdf
@@@