Skip to content

Add 'Copy page' button to fetch and copy raw Markdown#5

Open
zamal-db wants to merge 1 commit intokrypticmouse:masterfrom
zamal-db:feat/copy-as-markdown
Open

Add 'Copy page' button to fetch and copy raw Markdown#5
zamal-db wants to merge 1 commit intokrypticmouse:masterfrom
zamal-db:feat/copy-as-markdown

Conversation

@zamal-db
Copy link

Summary

Adds a Copy page button ( icon + label) next to the Edit this page link on every doc page. One click fetches the raw Markdown source from GitHub and copies it to the clipboard.

Motivation

Users working with LLMs or note-taking tools often need raw Markdown of a doc page. Today the only way is: Edit this page GitHub Raw manually copy. This button does it in one click.

Changes

File What
docs/js/copy-as-markdown.js Derives .md path from edit link, fetches from raw.githubusercontent.com, copies via Clipboard API, shows feedback
docs/stylesheets/extra.css Minimal CSS for button states (loading, success, error)
mkdocs.yml Registers the script in extra_javascript

How it works

  1. Reads the edit link href to resolve the exact .md path
  2. Fetches raw source from raw.githubusercontent.com/stanfordnlp/dspy/main/docs/docs/...
  3. Falls back to /index.md for directory-style pages
  4. Copies to clipboard green Copied! (or red on error), resets after 2s
  5. Works with MkDocs Material instant navigation (document$.subscribe)

Testing

  • Built and served locally with mkdocs build / python -m http.server
  • Verified on regular pages, API reference, and directory index pages
  • Confirmed raw Markdown is correctly fetched and copied to clipboard

@vercel
Copy link

vercel bot commented Feb 24, 2026

Someone is attempting to deploy a commit to the DSPy Team on Vercel.

A member of the Team first needs to authorize it.

Adds a clipboard button next to the existing 'Edit this page' action on
every documentation page. Clicking it fetches the raw Markdown source
from GitHub and copies it to the user's clipboard.

- New file: docs/js/copy-as-markdown.js
- Minimal CSS additions in docs/stylesheets/extra.css
- Registered script in mkdocs.yml extra_javascript
@zamal-db zamal-db force-pushed the feat/copy-as-markdown branch from 9ac4dda to 25abe51 Compare February 24, 2026 09:50
@krypticmouse
Copy link
Owner

krypticmouse commented Feb 24, 2026

Hi @zamal-db

Thank you so much for the PR! We usually avoid making PRs to this repo can you please make these additions in the main repo here instead: https://github.com/stanfordnlp/dspy/tree/main/docs

Any changes you make there will be automatically synced here and this repo is mostly for vercel deployment.

@zamal-db
Copy link
Author

Thanks for the pointer! I've opened the PR on the main repo instead: stanfordnlp/dspy#9327

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.

2 participants