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

@@ -12,7 +12,8 @@ class Cell:
def __init__(self, text, font, hpos,
top, right, bottom, left,
left_all, right_all,
rowspan, colspan, first_column=False, hpos_forced=False):
rowspan, colspan, first_column=False, hpos_forced=False,
fit_class="", flush_left=False, flush_right=False):
self.text = text
self.font = font
self.hpos = hpos
@@ -23,6 +24,17 @@ class Cell:
self.rowspan = rowspan
self.colspan = colspan
self.first_column = first_column
# html only: the class(es) clamping a 'fit' column's cell to its
# widest entry -- "Wfit Wpct" in a full-width table, "Wfit" in a
# content-sized ('fill') table, "" when not a fit column.
self.fit_class = fit_class
# Cell sits on a table edge with no outer vertical line: its outer
# padding (html) / \tabcolsep (tex, via @{}) is removed so the text
# aligns with the text margin. A tex \multicolumn replaces the
# whole preamble entry including the @{}, so edge cells must
# re-emit it in their own spec.
self.flush_left = flush_left
self.flush_right = flush_right
#print("Cell:", text, hpos)
def __str__(self):
@@ -47,6 +59,12 @@ class Cell:
if pred:
result.cls(cls_name)
result.cls(f"H{self.hpos}")
if self.fit_class:
result.cls(self.fit_class)
if self.flush_left:
result.cls("Fl")
if self.flush_right:
result.cls("Fr")
return result.str()
def tex(self, debug=False): # , left_line, right_line):
@@ -70,6 +88,10 @@ class Cell:
pos = "|" + pos
if self.border.right:
pos = pos + "|"
if self.flush_left:
pos = "@{}" + pos
if self.flush_right:
pos = pos + "@{}"
return f"\\multicolumn{{{self.colspan}}}{{{pos}}}{{{result}}}"
remove_left = self.border.left_all and not self.border.left
remove_right = self.border.right_all and not self.border.right
@@ -83,6 +105,10 @@ class Cell:
pos = "|" + pos
if self.border.right_all and self.border.right:
pos = pos + "|"
if self.flush_left:
pos = "@{}" + pos
if self.flush_right:
pos = pos + "@{}"
result = f"\\multicolumn{{1}}{{{pos}}}{{{result}}}"
return result