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

@@ -26,6 +26,46 @@ std::string document(Machine& machine)
}
}
// Print a console warning for each KT-WIDE-TABLE marker a table's runtime
// width check (tex_width_check() in table.py) left in the xelatex log,
// followed by a short :column_width primer. Plain line scanning -- no
// std::regex over the (arbitrarily large) log text.
static void warn_wide_tables(const std::string& xelatex_log)
{
bool any = false;
std::istringstream lines(xelatex_log);
std::string line;
while (std::getline(lines, line)) {
auto pos = line.find("KT-WIDE-TABLE ");
if (pos == std::string::npos) continue;
if (!any) {
std::cerr << yellow
<< "Warning: a table is wider than the text column "
<< "and extends past the right margin:\n";
any = true;
}
std::string detail = line.substr(pos + 14);
// The log's newline encoding can leave a trailing backslash.
while (!detail.empty() &&
(detail.back() == '\\' || detail.back() == ' '))
detail.pop_back();
std::cerr << " " << detail << "\n";
}
if (any) {
std::cerr <<
" The :column_width values and how they interact:\n"
" fit the column's widest entry, never wrapped\n"
" fill the width left over after the other columns, but\n"
" no more than the widest entry; wraps when needed\n"
" 0.0-1.0 that fraction of the text column width\n"
" * the width left over, unconditionally (the table\n"
" always spans the full text column)\n"
" A long-text column set to \"fit\" never wraps and pushes\n"
" the table off the page; give it \"fill\" instead.\n"
<< black;
}
}
extern "C"
std::string tex_to_pdf(Machine& machine)
{
@@ -67,6 +107,7 @@ std::string tex_to_pdf(Machine& machine)
throw Definition_error(ss.str(), Locator(), false);
}
}
warn_wide_tables(xelatex_log);
/*
if (std::stoi(machine.m_state.value("K_verbose_level")) < 2) {
for (auto ext : word_split("tex out aux log toc")) {