Escaping, table layout, and document fixes

Quoted Klammertext specials (^@ ^| ^# ^^ ^: ^*) and ^'...'^ regions now
survive re-processing (held as escape markers until final output);
:after_apply phase functions receive and return raw target text.

Tables: :hpos element position (center|left|right|<length>) replaces the
unimplemented :center/:indent; the ranged cell override is renamed
:justify; :column_width works in html (colgroup widths) and gains
'fill' -- the remaining width, capped at the column's widest entry, in
both targets; a table wider than the text column warns on the console;
table edges without an outer line set their text flush on the margins.

@document: no empty title bar for untitled documents; @vfill fills to
the bottom of the window in html (pure CSS); @vspace in plain text;
new @dot klammer; monospace email links.
This commit is contained in:
2026-07-25 21:16:21 +02:00
parent 4262fc6136
commit d61336b191
26 changed files with 650 additions and 75 deletions

View File

@@ -8,6 +8,7 @@
#include "log.h"
#include "show.h"
#include "character.h"
#include "target.h"
std::string to_string(std::vector<Katom>::const_iterator begin, std::vector<Katom>::const_iterator end, bool trim_result)
{
@@ -299,7 +300,75 @@ void mark_literal_katoms(katom_list& katoms)
//end->m_type = katom_t::replaced;
mark_as_replaced(*(end - 1));
//std::for_each(begin + 1, end, [](Katom& k) { k.m_type = katom_t::literal; });
std::for_each(begin + 1, end - 1, mark_as_literal);
// Hide Klammertext structural characters in the content as KTESC
// markers so the literal text survives re-katomization (the
// @document :text sub-Machine, the @eval result read-back).
// Resolved back to the characters at final processing. Literal
// KLAMMER content (@code) is NOT treated this way -- it is marked
// by mark_literal_klammer_content() and reaches the @eval code raw.
std::for_each(begin + 1, end - 1, [](Katom& k) {
mark_as_literal(k);
k.m_text = hide_structural_characters(k.m_text);
});
}
}
}
void hide_special_katoms(katom_list& katoms)
{
// Replace the text of ^-quoted special-character katoms (^@, ^|, ^#, ^^,
// ^:, ^*) with KTESC markers. The katomizer strips the "^" when the
// katom is constructed, so without this the bare character leaks into
// assembled strings (state values, @eval results) and is re-interpreted
// as Klammertext syntax when those strings are re-katomized -- by
// @document's :text sub-Machine or the @eval result read-back in
// Eval::eval. Markers are inert text at every level and are resolved to
// the characters at final processing (Target::resolve_escapes).
//
// Skipped inside:
// * @@...@@ and @@@...@@@ definition spans -- parameter declarations,
// descriptions, and argtype patterns are extracted as plain strings
// (kdesc display, validation regexes); a klammer BODY is re-processed
// through process_katoms() at application time, outside any
// definition span, so its quoted specials are hidden then.
// * @eval/@read/@cond argument spans -- code, filenames, and
// predicates consumed by the primitive, not target text (the same
// rule as the general-body escape pass in Machine::apply_klammer).
(void)K::log(4);
int definition_depth = 0;
int code_depth = 0; // inside an @eval/@read/@cond span
std::vector<bool> apply_is_code; // one entry per open application
for (auto& k : katoms) {
switch (k.m_type) {
case katom_t::define_begin:
case katom_t::machine_begin:
++definition_depth;
continue;
case katom_t::define_end:
case katom_t::machine_end:
if (definition_depth > 0) --definition_depth;
continue;
case katom_t::eval_begin:
case katom_t::read_begin:
case katom_t::cond_begin:
apply_is_code.push_back(true);
++code_depth;
continue;
case katom_t::apply_begin:
apply_is_code.push_back(false);
continue;
case katom_t::apply_end:
if (!apply_is_code.empty()) {
if (apply_is_code.back()) --code_depth;
apply_is_code.pop_back();
}
continue;
default:
break;
}
if (k.m_type == katom_t::special &&
definition_depth == 0 && code_depth == 0) {
k.m_text = hide_structural_characters(k.m_text);
}
}
}