kuhy_credit: LaTeX stack for PDF documents

Generated latex/kuhy-credit.sty draws the M1 logo as TikZ polygons and
links it to the site; compile E2E in pytest. Version 0.2.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-11-20 22:27:55 +01:00
parent 22e04baed7
commit 96fedf6442
13 changed files with 327 additions and 12 deletions

View File

@ -23,7 +23,8 @@ jobs:
with: { python-version: "3.15.2" }
- name: Install the package, pytest and a virtual X display
run: |
sudo apt-get update && sudo apt-get install -y xvfb python3-tk
sudo apt-get update && sudo apt-get install -y xvfb python3-tk \
texlive-latex-base texlive-latex-recommended texlive-pictures
pip install -r requirements-dev.txt && pip install --no-deps -e .
- name: Lint
run: ruff check . && ruff format --check .

View File

@ -5,7 +5,7 @@ repo_contract, coverage_gaps, crdt-sync, gatelock, freedays, sickdays, earned_ti
flutter_web_drive (headless Flutter-web E2E driver + MCP), ...).
`godot_dev_tools/` is a Godot addon (GDScript): `godot_dev_tools/test.sh` runs its GUT tests.
`kuhy_credit/` is the shared "Created by kuhy" credit, one implementation per stack (web, Flutter,
Godot, Tk, terminal) generated from `kuhy_credit/credit.json`; `kuhy_credit/README.md` lists each
Godot, Tk, terminal, LaTeX) generated from `kuhy_credit/credit.json`; `kuhy_credit/README.md` lists each
stack's test and E2E command, `python -m generator.generate --check` (from `kuhy_credit/`) the drift check.
Python packages with a root-level `<pkg>/tests` run with `PYTHONPATH=.`;
subprojects with their own `pyproject.toml` run via `scripts/run_subproject_tests.sh <dir>`.

View File

@ -21,13 +21,15 @@ Nothing loads over the network and nothing opens without a click.
| flutter | `flutter/lib/src/credit_data.g.dart` |
| godot | `godot/addons/kuhy_credit/credit_data.gd` |
| terminal | `terminal/kuhy-credit.sh` |
| latex | `latex/kuhy-credit.sty` |
- `python -m generator.generate --check` (from `kuhy_credit/`) fails and names
every stack whose file differs from the sources. CI runs it on every push.
## Decisions (change them here if you disagree)
- Placement: web footer, Flutter about screen, Godot main-menu corner. The
- Placement: web footer, Flutter about screen, Godot main-menu corner, PDF
(LaTeX) footer's right corner. The
panel opens above the logo, aligned to its end edge; each stack has a
"below" and a "start" option.
- Lockers and gate windows get no credit. The Tk widget ships but no locker
@ -40,7 +42,7 @@ Nothing loads over the network and nothing opens without a click.
```jsonc
// package.json
"@kuhyx/kuhy-credit": "github:kuhyx/utils#kuhy-credit-v0.1.0&path:kuhy_credit/web"
"@kuhyx/kuhy-credit": "github:kuhyx/utils#kuhy-credit-v0.2.0&path:kuhy_credit/web"
```
```html
@ -66,7 +68,7 @@ dependencies:
kuhy_credit:
git:
url: https://github.com/kuhyx/utils
ref: kuhy-credit-v0.1.0
ref: kuhy-credit-v0.2.0
path: kuhy_credit/flutter
```
@ -83,7 +85,7 @@ app on Android). Back closes an open panel. Demo: `flutter/example`.
```bash
cache="$(mktemp -d)"
git clone --depth 1 --branch kuhy-credit-v0.1.0 https://github.com/kuhyx/utils "$cache"
git clone --depth 1 --branch kuhy-credit-v0.2.0 https://github.com/kuhyx/utils "$cache"
cp -r "$cache/kuhy_credit/godot/addons/kuhy_credit" addons/
```
@ -99,7 +101,7 @@ The script opens the site with `OS.shell_open`. Demo:
## Python / Tkinter
```bash
pip install "kuhy-credit @ git+https://github.com/kuhyx/utils@kuhy-credit-v0.1.0#subdirectory=kuhy_credit"
pip install "kuhy-credit @ git+https://github.com/kuhyx/utils@kuhy-credit-v0.2.0#subdirectory=kuhy_credit"
```
```python
@ -112,6 +114,28 @@ The widget opens the site with `webbrowser` (a new tab). Tk has no rounded
corners and no accessibility tree, so those two parts of the design do not
apply there. Demo: `python -m kuhy_credit.demo [--light]`.
## LaTeX (PDF documents)
PDFs have no click-to-open panel, so the LaTeX stack draws the logo only (as
vector TikZ, no image file) and makes it a link to the site. No words appear.
```bash
# vendor the generated package from the tag, like the Godot addon
cache="$(mktemp -d)"
git clone --depth 1 --branch kuhy-credit-v0.2.0 https://github.com/kuhyx/utils "$cache"
cp "$cache/kuhy_credit/latex/kuhy-credit.sty" kuhy-credit/
TEXINPUTS="$PWD/kuhy-credit//:" pdflatex doc.tex
```
```latex
\usepackage{hyperref}
\usepackage{kuhy-credit} % after hyperref is fine, before it too
\fancyfoot[R]{\kuhycredit} % \kuhycredit[8mm] for another size
```
`\kuhycreditlogo[<size>]` draws the logo without a link. The default size is
`\kuhycreditsize` (12mm). Demo: `latex/demo/demo.tex`.
## Terminal programs
```bash
@ -136,6 +160,8 @@ print(credit_line()) # Created by kuhy https://kuhy.duckdns.org
| flutter web E2E | build `flutter/example` for web, then `python3 e2e/flutter_web_e2e.py` |
| godot + E2E | `godot/test.sh` (GUT; `tests/test_demo_e2e.gd` is the E2E) |
| Tk E2E | part of the pytest run: `tests/test_tk_e2e.py` |
| LaTeX E2E | part of the pytest run: `tests/test_latex.py` (needs pdflatex) |
Every E2E clicks the logo, then the panel, and checks the URL the stubbed
browser launch received.
browser launch received. The LaTeX E2E compiles the demo and checks the PDF's
link annotations carry the URL.

View File

@ -70,7 +70,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.0"
version: "0.2.0"
leak_tracker:
dependency: transitive
description:

View File

@ -3,7 +3,7 @@ description: >-
The shared "Created by kuhy" credit: an M1 logo button that opens a small
panel, whose tap opens kuhy.duckdns.org. Android and Flutter web.
publish_to: 'none'
version: 0.1.0
version: 0.2.0
environment:
sdk: ^3.12.2

View File

@ -168,3 +168,63 @@ def terminal(c: Credit) -> str:
"set -euo pipefail\n"
f"printf '%s %s\\n' {shlex.quote(c.text)} {shlex.quote(c.url)}\n"
)
_TEX_SPECIAL = set("\\{}%#$&^_~")
def _tex_safe(value: str) -> str:
"""Refuse a value that would need TeX escaping; the macros keep it verbatim."""
bad = sorted(set(value) & _TEX_SPECIAL)
if bad:
msg = f"TeX-special characters {bad} in {value!r}: the LaTeX stack cannot carry them"
raise ValueError(msg)
return value
def latex(c: Credit) -> str:
"""latex/kuhy-credit.sty."""
names = {c.logo.field: "kuhycreditfield"}
for s in c.logo.shapes:
names.setdefault(s.fill, f"kuhycreditfill{len(names)}")
colours = "".join(
f"\\definecolor{{{name}}}{{HTML}}{{{fill.lstrip('#').upper()}}}\n"
for fill, name in names.items()
)
def poly(points: tuple[float, ...]) -> str:
pairs = [f"({_num(points[i])},{_num(points[i + 1])})" for i in range(0, len(points), 2)]
return textwrap.fill(" ".join(pairs), 76, initial_indent=" ", subsequent_indent=" ")
shapes = "".join(
f" \\fill[{names[s.fill]}] plot coordinates {{\n{poly(s.points)}\n }} -- cycle;\n"
for s in c.logo.shapes
)
n = c.logo.size
return (
f"% The kuhy credit for LaTeX ({MARK}).\n"
"% \\kuhycredit[<size>] draws the logo linked to the site (needs hyperref);\n"
"% \\kuhycreditlogo[<size>] draws it without a link. Size defaults to\n"
"% \\kuhycreditsize (12mm, about the web stack's 48px).\n"
"\\NeedsTeXFormat{LaTeX2e}\n"
"\\ProvidesPackage{kuhy-credit}[kuhy credit]\n"
"\\RequirePackage{tikz}\n"
f"{colours}"
f"\\newcommand*\\kuhycreditURL{{{_tex_safe(c.url)}}}\n"
f"\\newcommand*\\kuhycreditText{{{_tex_safe(c.text)}}}\n"
"\\newlength\\kuhycreditsize\n\\setlength\\kuhycreditsize{12mm}\n"
"\\newcommand\\kuhycreditlogo[1][\\kuhycreditsize]{%\n"
f" \\pgfmathsetmacro\\kuhycredit@unit{{(#1)/{n}}}%\n"
" \\begin{tikzpicture}[x=\\kuhycredit@unit pt,y=-\\kuhycredit@unit pt,\n"
" baseline=(current bounding box.south)]\n"
f" \\fill[kuhycreditfield] (0,0) rectangle ({n},{n});\n"
f"{shapes}"
" \\end{tikzpicture}}\n"
"\\newcommand\\kuhycredit[1][\\kuhycreditsize]{%\n"
" \\ifdefined\\href{\\hypersetup{pdfborder={0 0 0}}%\n"
" \\href{\\kuhycreditURL}{\\kuhycreditlogo[#1]}}%\n"
" \\else\\kuhycreditlogo[#1]\\fi}\n"
"\\AtBeginDocument{\\ifdefined\\href\\else\\PackageWarningNoLine{kuhy-credit}%\n"
" {hyperref is not loaded: \\string\\kuhycredit\\space draws no link}\\fi}\n"
"\\endinput\n"
)

View File

@ -27,6 +27,7 @@ STACKS = {
"flutter": "flutter/lib/src/credit_data.g.dart",
"godot": "godot/addons/kuhy_credit/credit_data.gd",
"terminal": "terminal/kuhy-credit.sh",
"latex": "latex/kuhy-credit.sty",
}
_EMITTERS = {
"python": emit.python,
@ -34,6 +35,7 @@ _EMITTERS = {
"flutter": emit.flutter,
"godot": emit.godot,
"terminal": emit.terminal,
"latex": emit.latex,
}

View File

@ -0,0 +1,18 @@
% Demo of the LaTeX stack: build with TEXINPUTS pointing at kuhy_credit/latex.
% TEXINPUTS=../: pdflatex demo.tex (from kuhy_credit/latex/demo)
\pdfcompresslevel=0
\pdfobjcompresslevel=0
\documentclass{article}
\usepackage{fancyhdr}
\usepackage{hyperref}
\usepackage{kuhy-credit}
\setlength{\footskip}{48pt}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{\kuhycredit}
\begin{document}
\centering
\kuhycredit[40mm]\par\bigskip
\kuhycreditlogo
\end{document}

View File

@ -0,0 +1,141 @@
% The kuhy credit for LaTeX (generated by kuhy_credit/generator/generate.py; DO NOT EDIT).
% \kuhycredit[<size>] draws the logo linked to the site (needs hyperref);
% \kuhycreditlogo[<size>] draws it without a link. Size defaults to
% \kuhycreditsize (12mm, about the web stack's 48px).
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{kuhy-credit}[kuhy credit]
\RequirePackage{tikz}
\definecolor{kuhycreditfield}{HTML}{211D1B}
\definecolor{kuhycreditfill1}{HTML}{B8862E}
\definecolor{kuhycreditfill2}{HTML}{ECEAE9}
\newcommand*\kuhycreditURL{https://kuhy.duckdns.org}
\newcommand*\kuhycreditText{Created by kuhy}
\newlength\kuhycreditsize
\setlength\kuhycreditsize{12mm}
\newcommand\kuhycreditlogo[1][\kuhycreditsize]{%
\pgfmathsetmacro\kuhycredit@unit{(#1)/512}%
\begin{tikzpicture}[x=\kuhycredit@unit pt,y=-\kuhycredit@unit pt,
baseline=(current bounding box.south)]
\fill[kuhycreditfield] (0,0) rectangle (512,512);
\fill[kuhycreditfill1] plot coordinates {
(232.45,126.71) (235.4,121.83) (236.86,117.46) (237.16,113.16)
(236.11,108.55) (233.71,104.34) (230.14,100.74) (225.62,97.95)
(220.41,96.16) (214.75,95.51) (208.86,96.11) (202.89,97.96)
(196.97,101.02) (191.8,104.61) (186.14,109.43) (168.83,127.05)
(163.79,131.69) (158.86,135.08) (156.85,135.91) (155.0,136.26)
(153.32,136.1) (151.51,135.26) (150.17,134.03) (148.74,131.95)
(146.53,126.68) (142.68,113.58) (140.39,107.28) (137.47,101.8)
(134.17,98.03) (131.62,96.28) (129.3,95.34) (126.82,94.91)
(124.22,94.99) (121.55,95.59) (118.85,96.69) (116.18,98.26)
(113.59,100.29) (110.67,103.26) (108.46,106.12) (104.82,112.71)
(103.46,116.33) (102.26,120.85) (101.33,129.4) (101.51,134.83)
(102.18,140.16) (107.16,161.56) (107.92,166.59) (108.16,170.93)
(107.96,175.3) (107.23,180.39) (103.3,196.89) (102.03,203.6)
(101.44,209.71) (101.57,215.83) (102.56,221.84) (104.46,227.54)
(106.85,232.14) (110.3,236.77) (113.3,239.71) (117.11,242.44)
(120.52,244.13) (124.51,245.27) (128.36,245.46) (131.44,244.86)
(134.25,243.55) (137.1,241.19) (138.84,238.98) (140.33,236.37)
(142.79,229.46) (144.26,222.2) (146.91,203.45) (149.0,195.46)
(150.82,191.74) (152.78,189.39) (155.06,187.98) (157.64,187.54)
(160.46,188.07) (163.46,189.54) (166.57,191.89) (170.18,195.54)
(176.49,203.82) (187.93,221.96) (192.91,229.15) (198.18,235.26)
(203.3,239.57) (207.07,241.74) (210.4,243.03) (213.78,243.76)
(217.74,243.92) (221.07,243.47) (224.8,242.29) (228.25,240.44)
(230.89,238.38) (233.17,235.92) (235.02,233.11) (236.37,230.0)
(237.18,226.63) (237.42,223.07) (237.07,219.35) (236.13,215.54)
(234.6,211.66) (230.9,205.16) (225.43,198.15) (219.02,191.41)
(205.04,178.08) (200.57,173.11) (197.35,167.98) (196.49,165.31)
(196.29,163.13) (196.57,160.98) (197.54,158.44) (199.16,155.9)
(201.39,153.37) (206.78,148.63) (224.45,135.06) (228.82,130.95)
} -- cycle;
\fill[kuhycreditfill1] plot coordinates {
(439.15,304.62) (441.35,299.45) (442.51,294.18) (442.42,288.99)
(441.16,284.54) (438.79,280.56) (435.43,277.23) (431.27,274.73)
(426.09,273.1) (421.13,272.75) (416.7,273.37) (412.03,275.08)
(407.76,277.8) (404.33,280.97) (400.93,285.13) (391.39,300.46)
(387.52,305.61) (384.97,308.13) (382.62,309.84) (379.82,311.14)
(377.32,311.67) (374.44,311.56) (371.59,310.69) (368.84,309.1)
(366.22,306.86) (361.68,301.2) (353.72,288.2) (349.9,282.87)
(345.1,278.03) (339.97,274.81) (336.22,273.46) (332.8,272.84)
(328.82,272.8) (324.89,273.46) (321.18,274.78) (317.81,276.73)
(314.92,279.23) (312.64,282.19) (311.36,284.65) (310.49,287.28)
(310.02,290.04) (309.96,292.87) (310.28,295.74) (311.1,299.1)
(313.73,305.2) (316.79,310.09) (321.01,315.47) (337.3,332.65)
(344.34,340.99) (350.25,349.71) (354.13,357.71) (356.15,364.64)
(356.94,371.76) (356.69,378.61) (354.92,395.62) (354.93,400.36)
(355.46,405.02) (356.78,409.97) (358.95,414.48) (361.98,418.37)
(365.77,421.42) (369.24,423.14) (372.98,424.16) (376.83,424.43)
(380.67,423.95) (384.34,422.72) (387.71,420.81) (390.68,418.27)
(393.42,414.79) (394.87,412.17) (396.16,408.88) (397.04,405.4)
(397.53,401.79) (397.58,394.42) (395.86,378.48) (395.63,371.63)
(396.54,364.05) (398.85,356.69) (402.9,348.74) (408.61,340.49)
(415.36,332.56) (431.64,315.37) (435.86,309.98)
} -- cycle;
\fill[kuhycreditfill2] plot coordinates {
(272.87,180.5) (273.78,191.15) (275.43,199.68) (277.93,207.24)
(281.46,214.32) (286.01,220.83) (291.97,227.15) (298.81,232.68)
(306.29,237.38) (314.83,241.44) (323.65,244.37) (331.97,245.96)
(340.33,246.39) (348.69,245.62) (356.98,243.7) (365.74,240.46)
(374.17,236.11) (379.85,232.38) (385.15,228.16) (389.95,223.48)
(393.76,218.86) (397.03,213.89) (399.73,208.6) (401.84,203.03)
(403.53,196.59) (404.61,189.99) (405.3,181.99) (405.89,159.12)
(407.09,137.35) (407.21,129.01) (406.69,121.27) (405.6,115.09)
(403.79,109.27) (401.53,104.61) (398.24,100.21) (394.25,96.96)
(389.72,95.06) (385.41,94.63) (381.04,95.41) (376.28,97.71)
(371.95,101.35) (368.3,106.12) (366.03,110.43) (364.13,115.78)
(363.07,120.69) (362.53,126.4) (362.58,131.38) (363.12,136.95)
(366.62,155.29) (367.54,162.94) (367.32,171.38) (366.55,176.01)
(365.5,179.98) (363.26,185.87) (360.61,190.86) (357.41,195.43)
(353.74,199.38) (349.69,202.52) (345.92,204.46) (342.02,205.56)
(338.06,205.77) (334.12,205.08) (330.28,203.52) (326.61,201.16)
(322.73,197.62) (319.27,193.35) (316.32,188.55) (313.95,183.43)
(312.21,178.16) (310.8,170.23) (310.73,162.45) (311.59,155.45)
(315.0,137.8) (315.74,128.01) (315.47,123.01) (314.68,118.04)
(313.31,113.22) (311.38,108.68) (308.91,104.56) (305.95,101.0)
(302.59,98.14) (298.95,96.07) (295.15,94.89) (291.33,94.64)
(287.61,95.31) (284.11,96.89) (281.8,98.52) (279.7,100.54)
(277.81,102.91) (275.86,106.15) (273.2,112.94) (271.66,120.41)
(271.11,126.72) (271.03,133.73) (272.32,158.32)
} -- cycle;
\fill[kuhycreditfill2] plot coordinates {
(142.5,408.93) (144.93,412.86) (148.33,416.82) (151.62,419.58)
(155.73,421.94) (159.96,423.33) (164.11,423.69) (168.0,423.04)
(171.46,421.41) (173.61,419.69) (175.81,417.09) (177.3,414.53)
(178.71,411.07) (180.34,403.92) (181.9,389.45) (182.76,384.3)
(184.38,379.06) (186.6,375.03) (188.42,372.84) (190.56,370.93)
(193.02,369.3) (196.36,367.72) (203.33,365.93) (207.41,365.55)
(211.54,365.59) (218.2,366.61) (224.14,368.79) (226.71,370.32)
(228.97,372.13) (232.2,376.09) (234.21,380.29) (235.51,385.06)
(237.68,403.4) (239.06,409.98) (241.43,415.72) (243.06,418.13)
(244.99,420.16) (247.7,422.03) (250.76,423.22) (254.12,423.7)
(257.08,423.52) (260.7,422.61) (263.71,421.29) (267.19,419.06)
(269.9,416.7) (273.71,412.09) (276.7,406.63) (278.73,400.57)
(279.77,394.13) (279.87,387.57) (279.19,381.08) (277.76,374.06)
(273.42,357.39) (272.7,353.01) (272.43,348.73) (272.65,344.45)
(273.45,339.45) (277.62,323.51) (278.95,317.31) (279.71,311.68)
(279.93,306.77) (279.2,298.62) (277.23,291.66) (274.04,285.39)
(269.78,280.17) (267.06,277.83) (263.57,275.63) (260.56,274.33)
(256.94,273.46) (253.99,273.3) (250.64,273.8) (248.07,274.77)
(245.32,276.56) (243.34,278.53) (241.66,280.88) (239.2,286.54)
(237.66,293.75) (235.48,312.08) (233.95,317.39) (231.82,321.5)
(230.08,323.74) (228.0,325.7) (225.6,327.39) (222.9,328.79)
(216.76,330.71) (209.32,331.48) (201.85,330.81) (198.02,329.85)
(195.07,328.73) (192.39,327.32) (190.0,325.62) (187.94,323.64)
(186.21,321.39) (184.11,317.26) (182.6,311.93) (180.42,293.59)
(179.04,287.01) (177.76,283.44) (176.37,280.76) (174.68,278.43)
(172.69,276.48) (169.92,274.72) (167.34,273.77) (163.98,273.3)
(161.03,273.48) (157.4,274.38) (154.4,275.7) (150.92,277.93)
(148.21,280.29) (143.97,285.54) (141.1,291.09) (139.19,297.22)
(138.23,304.49) (138.34,311.05) (139.18,317.5) (144.55,338.96)
(145.64,347.04) (145.57,351.31) (144.91,356.27) (139.77,376.54)
(138.77,382.07) (138.23,387.76) (138.29,393.51) (139.06,399.17)
(140.59,404.59)
} -- cycle;
\end{tikzpicture}}
\newcommand\kuhycredit[1][\kuhycreditsize]{%
\ifdefined\href{\hypersetup{pdfborder={0 0 0}}%
\href{\kuhycreditURL}{\kuhycreditlogo[#1]}}%
\else\kuhycreditlogo[#1]\fi}
\AtBeginDocument{\ifdefined\href\else\PackageWarningNoLine{kuhy-credit}%
{hyperref is not loaded: \string\kuhycredit\space draws no link}\fi}
\endinput

View File

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "kuhy-credit"
version = "0.1.0"
version = "0.2.0"
description = "The shared 'Created by kuhy' logo credit: Tkinter widget and terminal line"
requires-python = ">=3.14"
dependencies = [] # pure stdlib: tkinter and webbrowser ship with Python

View File

@ -141,6 +141,7 @@ HAND_WRITTEN = [
"flutter/example/lib/main.dart",
"godot/addons/kuhy_credit/kuhy_credit.gd",
"godot/demo/demo.gd",
"latex/demo/demo.tex",
]

View File

@ -0,0 +1,66 @@
"""LaTeX stack: the generated package compiles and links the logo to the site."""
from __future__ import annotations
import json
import os
import re
import shutil
import subprocess
from pathlib import Path
import pytest
from generator import generate
CREDIT_DIR = Path(__file__).resolve().parents[1]
LATEX_DIR = CREDIT_DIR / "latex"
def test_latex_is_a_generated_stack() -> None:
assert generate.STACKS["latex"] == "latex/kuhy-credit.sty"
def _compile(tmp_path: Path) -> bytes:
"""Build latex/demo/demo.tex uncompressed and return the PDF bytes."""
pdflatex = shutil.which("pdflatex")
if pdflatex is None:
pytest.fail("pdflatex is required for the LaTeX stack E2E")
shutil.copy(LATEX_DIR / "demo/demo.tex", tmp_path)
env = {**os.environ, "TEXINPUTS": f"{LATEX_DIR}//:"}
subprocess.run(
[pdflatex, "-interaction=nonstopmode", "-halt-on-error", "demo.tex"],
cwd=tmp_path,
env=env,
check=True,
capture_output=True,
)
return (tmp_path / "demo.pdf").read_bytes()
def test_demo_pdf_links_the_logo_to_the_site(tmp_path: Path) -> None:
pdf = _compile(tmp_path)
url = json.loads((CREDIT_DIR / "credit.json").read_text())["url"]
# One link per \kuhycredit call in the demo, each with the shared URL.
assert pdf.count(f"/URI({url})".encode()) == 2
# The field and both glyph colours are painted (non-stroking rgb fills).
for rgb in (b"0.12941 0.11374 0.10588", b"0.72157 0.5255 0.18039", b"0.92549 0.91765 0.91374"):
assert rgb + b" rg" in pdf
# Links draw no border box: the logo is the only visible mark.
assert b"/Border[0 0 0]" in pdf
def test_logo_only_no_visible_words(tmp_path: Path) -> None:
"""The PDF shows the logo; the words live only in the link tooltip/metadata."""
pdf = _compile(tmp_path)
text = json.loads((CREDIT_DIR / "credit.json").read_text())["text"]
shown = re.findall(rb"\[\((.*?)\)\]\s*TJ", pdf)
assert not any(text.encode() in s for s in shown)
@pytest.mark.parametrize("value", ["https://x.org/a%20b", "50% off", "a_b"])
def test_tex_special_characters_are_refused(value: str) -> None:
from generator import emit
with pytest.raises(ValueError, match="TeX-special"):
emit._tex_safe(value)

View File

@ -1,6 +1,6 @@
{
"name": "@kuhyx/kuhy-credit",
"version": "0.1.0",
"version": "0.2.0",
"private": false,
"type": "module",
"description": "<kuhy-credit>: the shared 'Created by kuhy' logo credit as a dependency-free custom element.",