Files
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

71 lines
3.1 KiB
C++

#pragma once
// THE READ-TIME PASSES: katoms in, katoms out. What Machine::process_katoms()
// runs over a katom list once it exists -- encoding the ^-character forms,
// assembling ^UUUU UUUU^ sequences, marking literal and removed regions,
// hiding the quoted specials, finding spans, and delimiting @cond and
// klammer applications.
//
// Renamed from katom_list.{h,cpp} on 2026-09-02, which said "a list of
// katoms" and so described a data structure this file barely touches. It
// is named for the function it serves, which adds no vocabulary: text is
// KATOMIZED into KATOMs (katomize.{h,cpp}), and then PROCESSED here.
//
// The neighbours, and the line between them: katom.{h,cpp} is the katom
// itself and operations on a list of them; katomize.{h,cpp} turns text into
// katoms -- the one place a character stream enters. Nothing here takes
// characters, which is why none of it belongs there.
#include "katom.h"
#include "state.h"
std::string to_string(std::vector<Katom>::const_iterator begin, std::vector<Katom>::const_iterator end, bool trim_result=false);
std::string to_string(const std::vector<Katom>& katoms, bool trim_result=false);
// std::vector<Katom> process_katoms(
// const std::string& s, State& state, const std::string& source,
// bool nonascii=true, bool literal=true, bool ignore=true, bool whitespace=true,
// bool klammers=true, bool eval=true, bool cond=true, bool read=true);
bool level_increase(const Katom& k);
bool level_decrease(const Katom& k);
const katom_list::iterator
find_katom_named(const katom_list::iterator begin, const katom_list::iterator end, std::string name);
const std::vector<Katom>::iterator
find_katom(const std::vector<Katom>::iterator begin, const std::vector<Katom>::iterator end, size_t index);
std::vector<std::pair<Katom, Katom>>
find_spans(std::vector<Katom>::iterator begin, std::vector<Katom>::iterator end,
const std::function<bool(const Katom&)>& level_inc,
const std::function<bool(const Katom&)>& level_dec,
bool error_exit,
const std::string& name);
std::vector<std::pair<Katom, Katom>>
find_spans(std::vector<Katom>& katoms,
const std::function<bool(const Katom&)>& level_inc,
const std::function<bool(const Katom&)>& level_dec,
bool error_exit=true,
const std::string& name="all");
void describe_spans(const std::vector<Katom>& katoms);
std::pair<std::vector<Katom>::iterator, std::vector<Katom>::iterator>
find_span_katoms(std::vector<Katom>& katoms, const Katom& begin, const Katom& end);
std::pair<std::vector<Katom>::iterator, std::vector<Katom>::iterator>
find_span_katoms(
std::vector<Katom>::iterator kbegin, std::vector<Katom>::iterator kend, const Katom& begin, const Katom& end);
void encode_nonascii_characters(std::vector<Katom>& katoms);
void process_unicode_sequences(std::vector<Katom>& katoms);
void mark_literal_katoms(std::vector<Katom>& katoms);
void hide_special_katoms(std::vector<Katom>& katoms);
void mark_ignored_katoms(std::vector<Katom>& katoms);
void process_klammer_katoms(std::vector<Katom>& katoms);