Conversation
Fixes #72. Adds a 'Copy' button that appears on hover in the top-right corner of every code block (both standard Markdown fenced blocks and F# syntax-highlighted table.pre blocks). - docs/content/fsdocs-copy-button.js: new module that injects copy buttons via the Clipboard API (with execCommand fallback for non-HTTPS) - docs/content/fsdocs-default.css: styles for .copy-code-button and .code-block-wrapper (used to wrap table.pre for positioning) - docs/_template.html: load the new script - RELEASE_NOTES.md: document the addition Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
✅ Pull request created: #998 |
…ard-e89f0c91d528a99a
…ard-e89f0c91d528a99a
18 tasks
nojaf
reviewed
Feb 24, 2026
| function attachCopyHandler(button, getText) { | ||
| button.addEventListener('click', function () { | ||
| const text = getText() | ||
| if (navigator.clipboard && navigator.clipboard.writeText) { |
Collaborator
There was a problem hiding this comment.
/repo-assist while on topic, please update docs/content/fsdocs-tips.js as well to use navigator.clipboard.
Contributor
|
@nojaf Looks like |
…ard-e89f0c91d528a99a
Contributor
|
/repo-assist while on topic, please update docs/content/fsdocs-tips.js as well to use navigator.clipboard. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
Commit pushed:
|
dsyme
approved these changes
Feb 26, 2026
…ard-e89f0c91d528a99a
nojaf
approved these changes
Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated PR from Repo Assist, created in response to a maintainer request on #72.
Closes #72.
What this does
Adds a "Copy" button that appears on hover in the top-right corner of every code block in pages generated by
fsdocs. This makes it easy to copy F# snippets (including those with inline FSI output) directly into a.fsxfile.Root cause / context
Since 2013 (#72), there was no easy way to copy code samples from generated docs — especially F# highlighted blocks with inline output markers that make manual selection difficult.
Implementation
docs/content/fsdocs-copy-button.js(button class="copy-code-button")into everytable.pre(F# highlighted) andpre > code(Markdown fenced) block. Uses the modernnavigator.clipboardAPI with anexecCommandfallback for non-HTTPS environments.docs/content/fsdocs-default.css.copy-code-button(absolute-positioned, visible on hover) and.code-block-wrapper(a(div)wrapper used fortable.preblocks to provide a positioning context without breaking existing selectors).docs/_template.htmltype="module".RELEASE_NOTES.mdDesign decisions
table.preF# blocks: copies text from the.snippet precolumn, omitting line numbers.pre > codeblocks: copiesinnerTextof the<code>element.document.execCommand('copy')for pages served over plain HTTP.Test Status
Build: ✅
dotnet build FSharp.Formatting.sln --configuration Releasesucceeded (0 errors, 4 pre-existing warnings aboutSystem.Drawing.Commonvulnerability unrelated to this change).Note: The copy button is a pure front-end feature in template/CSS/JS files; there are no unit tests to run for it. Visual verification would require running
dotnet fsi build.fsxto generate docs.