TsukiNi22/ai-utils / skills/docs/html-style
html-style
VerifiedThe user's visual style for any HTML page (taken from html-doc - R-Type doc colors + context-forge layout) - color tokens for the light and dark themes, system font stacks and type scale, spacing / radius / layout / breakpoints, components (top bar, cards, callouts, tables, code blocks with copy, content tabs, sidebar, pager, SVG diagram classes, sun/moon theme switch, EN/FR switch), rules (responsive on phone, tablet, TV and touch screens, self-contained, no CDN / web font / gradient / emoji, WCAG contrast in both themes) - with scripts to build a self-contained page (new_page.py) and check a page or a palette (check_style.py). Use whenever creating or restyling an HTML page, a small web tool, a dashboard or a page component for the user, or when defining / changing a palette, color, font or theme, unless the user asks for another style.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 16.2 KB |
| scripts/check_render.pyexecutable | script | 27.1 KB |
| scripts/check_style.pyexecutable | script | 25.1 KB |
| scripts/new_page.pyexecutable | script | 4.0 KB |
| scripts/set_logo.pyexecutable | script | 6.1 KB |
| scripts/sync_nav.pyexecutable | script | 7.3 KB |
| templates/base.js | script | 20.1 KB |
| templates/page.html | other | 2.6 KB |
| templates/style.css | other | 25.2 KB |
scripts/sync_nav.py
View on GitHub#!/usr/bin/env python3
"""
Rebuild the navigation of every page of a folder (html-doc and explain-doc pages together) from the pages that
really exist, so that each skill links the pages of the other one.
Usage:
sync_nav.py [<docs dir>]
Each page declares its kind with <html data-page="guide|technical|graph|explain">; an explain page names its tab
with data-nav-title="AES" (default: the end of its <title>) and can set data-nav-order="2". A page with the level
switch of explain-doc but no data-page (made before this script) is detected and gets the attributes.
For every page:
- the top tabs (<nav class="tabs">): Guide, Technical, Graph, then the explanations; the current one marked,
hidden for a single page;
- the previous / next links (<nav class="pager">, when the page has one);
- the brand (logo, project name, version) copied from the html-doc page on every page, its link -> first page;
- the shared features of the top bar (GitHub link, EN / FR switch) on every page (a page without French
content is reported);
- the storage key of the explanation pages = the one of the html-doc pages (choices saved once for the site);
links between the pages also carry ?lang= / ?theme= / ?level= (base.js), for file:// where pages share nothing.
Pages are independent: removing one and re-running this script removes it everywhere.
"""
import glob
import html
import os
import re
import sys
ORDER = [("guide", "Guide"), ("technical", "Technical"), ("graph", "Graph")]
FEATURES = [("repo", r'<a class="icon-btn repo-link"[^>]*>.*?</a>'), ("lang", r'<div class="lang-switch".*?</div>')]
def nav_title(text: str, path: str) -> str:
m = re.search(r'<html[^>]*\bdata-nav-title="([^"]*)"', text)
if m:
return html.unescape(m.group(1))
m = re.search(r"<title>(.*?)</title>", text, re.S)
if m:
return html.unescape(re.split(r"\s[·|:-]\s", m.group(1).strip())[-1])
return os.path.splitext(os.path.basename(path))[0].replace("-", " ").title()
def main() -> int:
d = sys.argv[1] if len(sys.argv) > 1 else "docs"
fixed, explain = {}, []
for f in sorted(glob.glob(os.path.join(d, "*.html"))):
text = open(f, encoding="utf-8").read()
head = text[:3000]
m = re.search(r'<html[^>]*\bdata-page="(\w+)"', head)
kind = m.group(1) if m else ("explain" if 'class="level-switch"' in text else None)
if kind is None:
continue
if kind == "explain":
title = nav_title(text, f)
if not m: # page made before the attributes existed: declare it
text = re.sub(r"<html\b", f'<html data-page="explain" data-nav-title="{html.escape(title)}"', text, count=1)
open(f, "w", encoding="utf-8").write(text)
order = re.search(r'<html[^>]*\bdata-nav-order="(\d+)"', head)
explain.append((int(order.group(1)) if order else 999, os.path.basename(f), title))
elif kind not in fixed:
fixed[kind] = os.path.basename(f)
# One storage key for the whole site (theme / language / level saved once for every page): the key of the
# html-doc pages, else the one of the first page
keys = {}
for fn in list(fixed.values()) + [e[1] for e in explain]:
k = re.search(r'<html[^>]*\bdata-storage-key="([^"]*)"', open(os.path.join(d, fn), encoding="utf-8").read(3000))
if k and '{{' not in k.group(1):
keys.setdefault(fn, k.group(1))
site_key = next((keys[fn] for fn in fixed.values() if fn in keys), next(iter(keys.values()), None))
present = [(k, label, fixed[k]) for k, label in ORDER if k in fixed]
present += [("explain", title, fn) for _, fn, title in sorted(explain)]
if not present:
print(f"no page with data-page / level switch in {d}")
return 0
# One brand for the site (documentation logo + project name + version): the one of the html-doc pages
# (technical, guide, graph), else the one of the first page; every page gets the same
brand = None
for fn in [fixed[k] for k in ("technical", "guide", "graph") if k in fixed] + [e[2] for e in present]:
m = re.search(r'<a class="brand"[^>]*>.*?</a>', open(os.path.join(d, fn), encoding="utf-8").read(), re.S)
if m and "{{" not in m.group(0):
brand = m.group(0)
break
# Features of the top bar shared by the site (GitHub link, EN / FR switch): taken from the html-doc pages, else
# from any page, and added to the pages missing them; page specific ones (level switch) stay on their pages
shared = {}
for fn in [fixed[k] for k in ("technical", "guide", "graph") if k in fixed] + [e[2] for e in present]:
text = open(os.path.join(d, fn), encoding="utf-8").read()
for key, rx in FEATURES:
m = re.search(rx, text, re.S)
if key not in shared and m and "{{" not in m.group(0):
shared[key] = m.group(0)
warnings = []
for i, (kind, _, name) in enumerate(present):
path = os.path.join(d, name)
t = open(path, encoding="utf-8").read()
# Top tabs
links = "\n".join(f' <a href="{fn}"' + (' class="current" aria-current="page"' if fn == name else "")
+ f" data-i18n>{html.escape(label)}</a>" for _, label, fn in present)
hidden = " hidden" if len(present) < 2 else ""
t = re.sub(r'<nav class="tabs"[^>]*>.*?</nav>', f'<nav class="tabs" aria-label="Pages"{hidden}>\n{links}\n </nav>',
t, count=1, flags=re.S)
# Previous / next
prev_ = present[i - 1] if i > 0 else None
next_ = present[i + 1] if i + 1 < len(present) else None
pager = ""
if prev_:
pager += f'\n <a class="prev" href="{prev_[2]}"><span data-i18n>Previous</span><b data-i18n>{html.escape(prev_[1])}</b></a>'
if next_:
pager += f'\n <a class="next" href="{next_[2]}"><span data-i18n>Next</span><b data-i18n>{html.escape(next_[1])}</b></a>'
t = re.sub(r'<nav class="pager"[^>]*>.*?</nav>', f'<nav class="pager" aria-label="Pages">{pager + chr(10) if pager else ""}</nav>',
t, count=1, flags=re.S)
add = ""
for key, rx in FEATURES:
if key in shared and not re.search(rx, t, re.S):
add += "\n " + shared[key] + ("\n <span class=\"divider\" aria-hidden=\"true\"></span>" if key == "repo" else "")
if add:
t = t.replace('<div class="top-actions">', '<div class="top-actions">' + add, 1)
if "lang" in shared and not re.search(r'<[a-z][a-z0-9]*\b[^>]*\sdata-lang="fr"', t): # a tag, not the CSS selector
warnings.append(f"{name}: EN / FR switch but no French content (data-lang=\"fr\"): write the French version")
if brand:
t = re.sub(r'<a class="brand"[^>]*>.*?</a>', lambda m: brand, t, count=1, flags=re.S)
t = re.sub(r'(<a class="brand" href=")[^"]*(")', rf"\g<1>{present[0][2]}\2", t, count=1)
if site_key and kind == "explain": # html-doc pages keep theirs (also used by the graph config)
t = re.sub(r'(<html[^>]*\bdata-storage-key=")[^"]*(")', rf"\g<1>{site_key}\2", t, count=1)
open(path, "w", encoding="utf-8").write(t)
print(", ".join(f"{label} -> {fn}" for _, label, fn in present))
for w in warnings:
print("warning: " + w)
return 0
if __name__ == "__main__":
sys.exit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |