Three whitepaper-HTML-only fixes: * docutils's responsive.css blanket-pads every `body > *` with `padding: 0.5rem calc(29% - 7.2rem)`. The uncloseai floating button gets appended to <body>, picks up that padding, and blows from its designed 121 px to nearly half the viewport. Scoped override resets the cascade on the button selector with `all: revert` + explicit zero padding/margin. * whitepaper h1/h2 titles now use ChunkFive (same face as the homepage logo) instead of docutils's default serif. Font embedded as a base64 data: URI inside a <style> block so the HTML stays self-contained — no external font fetch. * RST layout: λ logo now sits UNDER the "Lumbda" heading instead of above it. Permacomputer logo still follows below the λ. New helper: whitepaper/inject-whitepaper-css.py runs after embed-images.py, reads ChunkFive from www/fonts/..., base64-encodes, writes the <style> block before </head>. Makefile wires it in.
75 lines
2.4 KiB
Python
75 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
# Inject whitepaper-specific CSS overrides into the rst2html5 output:
|
|
#
|
|
# 1. Embed the ChunkFive webfont (base64 woff2) and assign it to h1 /
|
|
# h2, so whitepaper titles read in the same voice as the homepage
|
|
# logo instead of docutils's default serif fallback.
|
|
#
|
|
# 2. Cancel docutils's responsive.css `body > *` rule for the
|
|
# uncloseai floating button — that rule slaps `padding: 0.5rem
|
|
# calc(29% - 7.2rem)` onto every direct child of <body>, which
|
|
# blows the 121px button up to ~40% of the viewport width. Scoped
|
|
# override plus `all: revert` so the button falls back to its own
|
|
# stylesheet's intended sizing.
|
|
#
|
|
# Usage: inject-whitepaper-css.py <html-file> <chunkfive-woff2-path>
|
|
|
|
import base64
|
|
import os
|
|
import sys
|
|
|
|
|
|
TEMPLATE = """\
|
|
<style>
|
|
@font-face {{
|
|
font-family: 'chunkfive';
|
|
src: url(data:font/woff2;base64,{woff2_b64}) format('woff2');
|
|
font-weight: normal;
|
|
font-style: normal;
|
|
font-display: swap;
|
|
}}
|
|
main > h1, main > h2, section > h2 {{
|
|
font-family: 'chunkfive', Georgia, serif;
|
|
font-weight: normal;
|
|
letter-spacing: 0.01em;
|
|
}}
|
|
/* docutils's responsive.css blanket-pads every `body > *`, which
|
|
explodes the uncloseai floating button to nearly half the viewport.
|
|
Revert the cascade inside that button so its own stylesheet wins. */
|
|
body > button#floating-ai-button,
|
|
body > .uncloseai-floating-button {{
|
|
all: revert;
|
|
padding: 0 !important;
|
|
margin: 0 !important;
|
|
max-width: none !important;
|
|
background-color: transparent !important;
|
|
}}
|
|
</style>
|
|
"""
|
|
|
|
|
|
def main(argv):
|
|
if len(argv) != 3:
|
|
sys.stderr.write("usage: inject-whitepaper-css.py <html-file> <chunkfive-woff2-path>\n")
|
|
return 2
|
|
html_path, woff2_path = argv[1], argv[2]
|
|
if not os.path.isfile(woff2_path):
|
|
sys.stderr.write(f"inject-whitepaper-css: chunkfive missing: {woff2_path}\n")
|
|
return 1
|
|
with open(woff2_path, "rb") as f:
|
|
woff2_b64 = base64.b64encode(f.read()).decode()
|
|
style_block = TEMPLATE.format(woff2_b64=woff2_b64)
|
|
with open(html_path, "r") as f:
|
|
html = f.read()
|
|
if "</head>" not in html:
|
|
sys.stderr.write("inject-whitepaper-css: no </head> found\n")
|
|
return 1
|
|
html = html.replace("</head>", style_block + "</head>", 1)
|
|
with open(html_path, "w") as f:
|
|
f.write(html)
|
|
print(f"inject-whitepaper-css: injected {len(style_block)} bytes into {html_path}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main(sys.argv))
|