diff --git a/.github/pages/build.py b/.github/pages/build.py
index 3663434..b8074af 100644
--- a/.github/pages/build.py
+++ b/.github/pages/build.py
@@ -25,6 +25,9 @@
HERE = pathlib.Path(__file__).resolve().parent
REPO_URL = "https://github.com/barkz/glean-code-cli"
+# What the browser tab says. Deliberately the command you type, not the prose
+# title -- the hidden
below still carries the product name.
+SITE_TITLE = "glean_code_cli"
BLOB_URL = REPO_URL + "/blob/main/"
# Directories copied next to index.html so relative image paths keep working.
@@ -286,14 +289,14 @@ def build(out_dir=None, root=None):
markdown = (root / "README.md").read_text(encoding="utf-8")
template = (HERE / "template.html").read_text(encoding="utf-8")
- title = page_title(markdown)
+ heading = page_title(markdown)
content = render(markdown)
if "
" chevron and an "_" cursor.
+CHEVRON = ((10.0, 10.0), (17.0, 16.0), (10.0, 22.0))
+STROKE_HALF = 1.6
+CURSOR = (18.6, 20.4, 26.0, 23.0) # x0, y0, x1, y1
+
+
+def svg():
+ return (
+ '\n"
+ )
+
+
+def _distance_to_segment(px, py, ax, ay, bx, by):
+ dx, dy = bx - ax, by - ay
+ span = dx * dx + dy * dy
+ t = 0.0 if span == 0 else ((px - ax) * dx + (py - ay) * dy) / span
+ t = max(0.0, min(1.0, t))
+ cx, cy = ax + t * dx, ay + t * dy
+ return ((px - cx) ** 2 + (py - cy) ** 2) ** 0.5
+
+
+def _coverage(u, v, edge):
+ """How much of the pixel at grid point (u, v) the mark covers, 0..1."""
+ inside_cursor = (CURSOR[0] <= u <= CURSOR[2]) and (CURSOR[1] <= v <= CURSOR[3])
+ if inside_cursor:
+ return 1.0
+ nearest = min(
+ _distance_to_segment(u, v, CHEVRON[0][0], CHEVRON[0][1], CHEVRON[1][0], CHEVRON[1][1]),
+ _distance_to_segment(u, v, CHEVRON[1][0], CHEVRON[1][1], CHEVRON[2][0], CHEVRON[2][1]),
+ )
+ # linear ramp across one pixel for a clean edge
+ return max(0.0, min(1.0, (STROKE_HALF - nearest) / edge + 0.5))
+
+
+def png_rows(size=PNG_SIZE):
+ scale = size / 32.0
+ edge = 1.0 / scale
+ rows = []
+ for y in range(size):
+ v = (y + 0.5) / scale
+ row = bytearray()
+ for x in range(size):
+ u = (x + 0.5) / scale
+ alpha = _coverage(u, v, edge)
+ for channel in range(3):
+ base, mark = PLATE[channel], MARK[channel]
+ row.append(int(round(base + (mark - base) * alpha)))
+ rows.append(bytes(row))
+ return rows
+
+
+def _chunk(kind, payload):
+ return (struct.pack(">I", len(payload)) + kind + payload
+ + struct.pack(">I", zlib.crc32(kind + payload) & 0xFFFFFFFF))
+
+
+def png(size=PNG_SIZE):
+ raw = b"".join(b"\x00" + row for row in png_rows(size))
+ return b"".join([
+ b"\x89PNG\r\n\x1a\n",
+ _chunk(b"IHDR", struct.pack(">IIBBBBB", size, size, 8, 2, 0, 0, 0)),
+ _chunk(b"IDAT", zlib.compress(raw, 9)),
+ _chunk(b"IEND", b""),
+ ])
+
+
+def main():
+ SVG_OUT.write_text(svg(), encoding="utf-8")
+ PNG_OUT.write_bytes(png())
+ print("wrote %s and %s (%d bytes)" % (SVG_OUT.name, PNG_OUT.name, PNG_OUT.stat().st_size))
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/.github/pages/template.html b/.github/pages/template.html
index 6db266f..47fa185 100644
--- a/.github/pages/template.html
+++ b/.github/pages/template.html
@@ -5,6 +5,8 @@
{{TITLE}}
+
+
@@ -251,7 +253,7 @@