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:
@@ -193,8 +193,27 @@ def element_tag(element):
|
||||
def font_class(font):
|
||||
return {"r" : "", "i" : "ritalic", "t" : "monospace", "s" : "sanserif"}[font]
|
||||
|
||||
def hpos_container(element, hpos):
|
||||
# Wrap element in its horizontal-position container. hpos is left,
|
||||
# center, right, none, or a length, which becomes the left margin
|
||||
# (the tex counterparts are the \LTleft glue for tables and the
|
||||
# \hspace* in latex_util.caption_wrapper).
|
||||
style = None
|
||||
if hpos not in ("left", "center", "right", "none"):
|
||||
length, _, _ = kutil.parse_length("html", hpos, 1)
|
||||
style = f"margin-left: {length}"
|
||||
hpos = "indent"
|
||||
result = E("div").cls("hpos_" + hpos).body(element)
|
||||
if style:
|
||||
result.attr("style", style)
|
||||
if hpos not in ("center", "indent"):
|
||||
result.cls("hpos_margin")
|
||||
return result
|
||||
|
||||
|
||||
def add_caption(element, caption_label, number, caption_text,
|
||||
font_symbol="i", hpos="center", side="bottom", as_string=True, font_size=.9):
|
||||
font_symbol="i", hpos="center", side="bottom", as_string=True,
|
||||
font_size=.9, width=None, max_width=None):
|
||||
tag = element_tag(element)
|
||||
# Caption
|
||||
caption = ""
|
||||
@@ -232,12 +251,19 @@ def add_caption(element, caption_label, number, caption_text,
|
||||
#print("-"*80)
|
||||
|
||||
element = E("div").cls("caption_" + side).attr("data-label", caption_label).body(element)
|
||||
if width:
|
||||
# The element's width (e.g. a table's :column_width total) lives
|
||||
# on this wrapper: the element fills it, and the caption tracks
|
||||
# the element.
|
||||
element.attr("style", f"width: {width}")
|
||||
elif max_width:
|
||||
# A content-sized element (a 'fill' table): the wrapper shrinks
|
||||
# to it but never past the text column, so the element wraps at
|
||||
# narrow windows instead of overflowing.
|
||||
element.attr("style", f"max-width: {max_width}")
|
||||
|
||||
|
||||
result = element
|
||||
result = E("div").cls("hpos_" + hpos).body(element)
|
||||
if hpos != "center":
|
||||
result = result.cls("hpos_margin")
|
||||
result = hpos_container(element, hpos)
|
||||
|
||||
if number:
|
||||
result.cls("element_container")
|
||||
|
||||
Reference in New Issue
Block a user