Skip to content

Feature: "Copy as Markdown" for page and section content #3444

Description

@schickling

Title

Feature: Copy as Markdown for page and section content

Summary

  • Add an optional "Copy as Markdown" action that copies either:
    • the entire page, or
    • the current section (from the focused heading to the next same-level heading).
  • Goal: make it effortless to share docs context with AI assistants, agentic coding tools, and issue trackers while preserving Markdown semantics.

Motivation

  • This is becoming a common pattern on modern docs sites. The Anthropic docs (https://docs.anthropic.com/) are a good example of AI-friendly documentation with strong copy interactions geared for downstream tooling.
  • Starlight already provides copy buttons for code blocks via Expressive Code; extending this to page/section content unlocks high‑value AI and agent workflows.

Edge Cases

  • Interactive/MDX-only components: degrade gracefully with best-effort Markdown.
  • Image/asset paths: preserve relative URLs by default; allow an option to absolutize links.
  • Tables/admonitions: ensure readable, portable Markdown output.

Configuration (example)

// starlight.config.ts
export default defineConfig({
  // ...
  copyMarkdown: {
    enabled: true,
    scope: 'both', // 'page' | 'section' | 'both'
    includeFrontmatter: false,
    linkStyle: 'inline', // 'inline' | 'reference'
    implementation: 'html-to-md', // 'html-to-md' | 'static-asset'
  },
})

Prior Art

Request

  • Would this belong in core Starlight or as an official plugin?
  • If the direction sounds good, I’m happy to help with an initial prototype/PR.

Screenshots / examples

  • Anthropic docs:

    Claude docs overview screenshot

  • zod.dev refinements section:

    zod.dev refinements screenshot

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions