Verbatim-safe typography, ^-punctuation quoting, full-range ^UUUU^, polyglot html
Typographic transforms (---, quote pairs, ~) no longer touch verbatim text: @c/@code/@source_listing content and ^'...'^ spans show exactly the characters written. "^" before any punctuation character quotes it in every target (the apostrophe excepted: ^' opens a literal span), with the new :resolve option on @@@target declaring per-target renderings. The ^UUUU^ code-point form accepts 4-6 hex digits, the full Unicode range. The html output and transform spellings are polyglot (XML-valid), in preparation for an EPUB target. New suites: transform_test, character_test (engine), typography_test (SKS). (from dev 07ce5ea86a0a)
This commit is contained in:
@@ -35,7 +35,7 @@ def block(material):
|
||||
required to know that a target distinguishes horizontal from
|
||||
vertical mode. Asserted by sks/tst/paragraph_test.sh.
|
||||
"""
|
||||
return "\\par\n" + material.strip("\n") + "\n\\par\n"
|
||||
return "^'\\par'^\n" + material.strip("\n") + "\n^'\\par'^\n"
|
||||
|
||||
def environment(name, body, required=None, optional=None):
|
||||
req = f"{{{required}}}" if required else ""
|
||||
@@ -164,3 +164,35 @@ def add_caption(element, caption_label, number, caption_text, latex_width,
|
||||
element = minipage(caption + "\\rule[-0.75\\baselineskip]{0pt}{0pt}\n" + element,
|
||||
latex_width, vertical="t")
|
||||
return caption_wrapper(element, hpos, offset=offset)
|
||||
|
||||
def define_color(name, rgb_or_hex):
|
||||
if "," in rgb_or_hex:
|
||||
r, g, b = [float(e) for e in rgb_or_hex.split(",")]
|
||||
else:
|
||||
def c(h):
|
||||
return float(eval('0x' + h)) / 255.0
|
||||
r = c(rgb_or_hex[:2])
|
||||
g = c(rgb_or_hex[2:4])
|
||||
b = c(rgb_or_hex[4:])
|
||||
return r'\\definecolor{{{}}}{{rgb}}{{{:.3f},{:.3f},{:.3f}}}'.format(name, r, g, b)
|
||||
|
||||
COLOR_BOX_TEMPLATE = r'''
|
||||
^'\hfill\begingroup
|
||||
COLOR
|
||||
\setlength{\fboxsep}{8pt}
|
||||
\fcolorbox{bordercolor}{localcolor}{
|
||||
\parbox{WIDTH\linewidth}{\raggedright\setlength{\parskip}{8pt}'^
|
||||
TEXT
|
||||
^'}}\endgroup'^
|
||||
'''.strip()
|
||||
|
||||
def color_box(text, width=1, box_color="1,1,1", border_color="0,0,0"):
|
||||
color_definitions = define_color("localcolor", box_color) + "\n" \
|
||||
+ define_color("bordercolor", border_color)
|
||||
result = COLOR_BOX_TEMPLATE
|
||||
for old, new in [['TEXT', re.sub(r'\\', r'\\\\', text)],
|
||||
['COLOR', color_definitions],
|
||||
['WIDTH', str(width)]]:
|
||||
result = re.sub(old, new, result)
|
||||
result = block(result)
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user