Skip to content

AI accessibility: per-page Markdown and llms.txt#5

Merged
shivamsn97 merged 1 commit into
mainfrom
feat/ai-accessibility
Jul 1, 2026
Merged

AI accessibility: per-page Markdown and llms.txt#5
shivamsn97 merged 1 commit into
mainfrom
feat/ai-accessibility

Conversation

@shivamsn97

Copy link
Copy Markdown
Member

AI accessibility — serve your app as Markdown

Opt-in llms feature: every page is available as clean Markdown (append .md, or send Accept: text/markdown), plus a generated /llms.txt index and Link/X-Llms-Txt discovery headers. Off by default; no page hot-path cost.

Where the Markdown comes from (first hit wins): a co-located <page>.md → a to_markdown handler in the page module → a to_markdown in the nearest-ancestor llms.py (subtree scope; pages/llms.py is app-wide) → opt-in dependency-free HTML→markdown autoConvert → a redirect to the page.

  • wrap_markdown(ctx, md) frames every .md with a header/footer; llms_txt(ctx) generates the index.
  • Handlers receive a MarkdownContext with request, path, run_loader(), and render_html().
  • No compiler changes — hooks are plain functions resolved at request time.

Docs: new AI accessibility guide, runtime-API reference for the hooks + context objects, and the config reference. Bumps 0.5.0 → 0.6.0.

Tests: tests/devserver/test_llms.py plus config and route tests; full suite green, coverage ≥ 95%.

Opt-in `llms` config block serves a clean Markdown rendition of every
page (append `.md`, or `Accept: text/markdown`), a generated `/llms.txt`
index, and `Link`/`X-Llms-Txt` discovery headers.

A page's Markdown is resolved from the project: a co-located `<page>.md`,
a `to_markdown` handler in the page module, or a `to_markdown` in the
nearest-ancestor `llms.py` (subtree scope; `pages/llms.py` is app-wide),
with an opt-in dependency-free HTML->markdown `autoConvert` fallback and
a redirect otherwise. A `wrap_markdown` hook frames every `.md`; a
`llms_txt` hook generates the index. Handlers receive a `MarkdownContext`
exposing `request`, `path`, `run_loader()`, and `render_html()`.

Off by default; adds nothing to the page hot path. Bumps 0.5.0 -> 0.6.0.
@shivamsn97 shivamsn97 merged commit cbc4115 into main Jul 1, 2026
5 checks passed
@shivamsn97 shivamsn97 changed the title feat: AI accessibility — per-page Markdown + llms.txt AI accessibility: per-page Markdown and llms.txt Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant