URL interception, conversion pipeline, discovery, and integrations.
Request path
- Rewrites —
parse_requestintercepts paths ending in.mdor/markdown, resolves the post withurl_to_postid(), and serves Markdown. Optional?markdown=trueon the canonical URL also serves Markdown. - Discovery —
wp_headinjectsrel="alternate"tags for both endpoints;/llms.txtis registered as its own rewrite. - Robots —
robots_txtinjects aContent-Signal:directive (and an agent-index comment referencing/llms.txt). - Accept negotiation — when
PRC_MARKDOWN_FOR_AGENTS_ENABLE_ACCEPT_NEGOTIATIONis true,template_redirectcan hijack responses forAccept: text/markdown. Disabled by default (VIP edge cache; Linear PRC-466).
Markdown_Response::serve() builds YAML frontmatter (Frontmatter::build()), converts blocks (Markdown_Converter), sets headers (Content-Type: text/markdown, Vary: Accept, X-Markdown-Tokens, Content-Signal, X-Robots-Tag: noindex), and exits.
Markdown serve path
Conversion
The converter walks the parsed block tree:
- Registered callbacks in
Block_Markdown_Registryproduce Markdown for that block name - Container blocks recurse into inner blocks
- Everything else falls through to
render_block()→HTML_To_Markdown_Converter
Post types opt in with add_post_type_support( $type, 'prc-markdown-for-agents' ).
Soft integrations
Guarded integrations enrich frontmatter or body when companion plugins are active:
| Integration | Effect |
|---|---|
prc-staff-bylines | authors frontmatter |
prc-datasets | datasets frontmatter |
prc-pdf-extraction | PDF extraction URL in frontmatter |
prc-report-package | TOC / next-chapter links in the body |
Settings REST (admin UI)
GET / POST /wp-json/prc-markdown-for-agents/v1/settings requires manage_options. These routes power Settings → Markdown for Agents and are not a public agent contract. Agents should use .md, /markdown, and /llms.txt.
Extension hooks
Primary extension points (full list in the plugin README):
prc_markdown_for_agents_register_block_callbacks— register block Markdown callbacksprc_markdown_for_agents_frontmatter— mutate frontmatter arraysprc_markdown_for_agents_after_markdown— append or transform body Markdownprc_markdown_for_agents_pre_markdown— short-circuit conversion with pre-built Markdown