Skip to content

feat(docs): add copy as markdown button to documentation pages (#2214) - #2242

Open
LestlinRobins wants to merge 4 commits into
Quantinuum:mainfrom
LestlinRobins:feat/copy-as-markdown
Open

LestlinRobins wants to merge 4 commits into
Quantinuum:mainfrom
LestlinRobins:feat/copy-as-markdown

Conversation

@LestlinRobins

Copy link
Copy Markdown
Contributor

Description

This PR adds a "Copy as Markdown" button to TKET documentation pages to make documentation content easily reusable in personal notes, technical documents, and AI coding assistants.

Key Implementation Details:

  • Clean Markdown Source Fetching: Fetches Sphinx's native source file (_sources/<page>.md.txt) instead of parsing the DOM, ensuring that raw Markdown formatting (math, code blocks, lists, headers) is preserved cleanly without copying navigation, headers, footers, or page chrome.
  • UI & Theme Integration: Integrates the button into .content-icon-container alongside the existing page actions (such as "View this page"), with full light/dark theme adaptation.
  • Responsive Layout: Displays both icon and text on desktop viewports while automatically collapsing to a compact icon-only button on mobile screens ($\le 67\text{em}$).
  • Clipboard Handling & Feedback: Uses navigator.clipboard.writeText with visual feedback (Copied! / Failed to copy) and includes a fallback for older environments.
  • Compatibility: Coexists seamlessly with the existing sphinx-copybutton extension for individual code blocks.

Related issues

Closes #2214

Checklist

  • I have performed a self-review of my code.
  • I have commented hard-to-understand parts of my code.
  • I have made corresponding changes to the public API documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the changelog with any user-facing changes.

@LestlinRobins

Copy link
Copy Markdown
Contributor Author

@cqc-alec I’ve made the required changes to support this feature. Please review them whenever you get a chance.

@cqc-alec
cqc-alec requested a review from CalMacCQ September 25, 2026 07:40
@LestlinRobins

Copy link
Copy Markdown
Contributor Author

@CalMacCQ All checks have passed successfully. When you have a chance, could you please review the PR and merge it if everything looks good? Thank you!

@LestlinRobins

Copy link
Copy Markdown
Contributor Author

@CalMacCQ Hi, could you please review the PR and merge it if everything looks good?
Thank you so much!

This branch has not been deployed

No deployments
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.

Add a “Copy as Markdown” button to TKET documentation pages

1 participant