npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

docsify-plugin-copy-as-markdown-button

v1.0.1

Published

Docsify plugin that adds a copy-as-Markdown button to every heading section

Readme

docsify-plugin-copy-as-markdown-button

npm license demo

A Docsify plugin that adds a Copy as Markdown button to every heading. Clicking it copies that section's raw Markdown to the clipboard — ideal for pasting into AI chats, where Markdown is understood far better than plain text or HTML.

Features

  • Appears on hover next to every h1h6 heading
  • Copies the heading and all its content as raw Markdown
  • Nested sections are included (content stops at the next heading of equal or higher level)
  • Headings inside fenced code blocks are correctly ignored
  • Light/dark mode aware via light-dark()
  • Visual feedback: checkmark on success, × on failure
  • Styles injected automatically — no separate CSS file needed
  • No dependencies, single file

Installation

Via CDN

Add the script after the Docsify script tag in your index.html:

<!-- minified (recommended) -->
<script src="//cdn.jsdelivr.net/gh/tucho235/[email protected]/docsify-plugin-copy-as-markdown.min.js"></script>

<!-- unminified -->
<script src="//cdn.jsdelivr.net/gh/tucho235/[email protected]/docsify-plugin-copy-as-markdown.js"></script>

Via npm

npm install docsify-plugin-copy-as-markdown-button

Then reference the file from node_modules:

<script src="node_modules/docsify-plugin-copy-as-markdown-button/docsify-plugin-copy-as-markdown.min.js"></script>

Manual

Download docsify-plugin-copy-as-markdown.js and place it in your project:

<script src="docsify-plugin-copy-as-markdown.js"></script>

No configuration needed. The plugin registers itself automatically.

Usage

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>My Docs</title>
  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css">
</head>
<body>
  <div id="app"></div>
  <script>
    window.$docsify = { name: 'My Docs' };
  </script>
  <script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.min.js"></script>
  <!-- Copy as Markdown plugin -->
  <script src="//cdn.jsdelivr.net/gh/tucho235/[email protected]/docsify-plugin-copy-as-markdown.js"></script>
</body>
</html>

How sections work

Each button copies the heading it belongs to plus everything that follows it, up to (but not including) the next heading at the same level or higher. For example:

## Installation        ← button copies from here…

Some text.

### Step 1             ← …down to here (level 2 ends when next level 2 starts)
### Step 2

## Usage               ← next level-2 heading, not included in "Installation"

Clicking the button on Installation copies:

## Installation

Some text.

### Step 1
### Step 2

Configuration

Pass options via window.$docsify.copyMarkdown before loading the plugin:

window.$docsify = {
  copyMarkdown: {
    buttonLabel:   'Copy section as Markdown', // button tooltip and aria-label
    flashDuration: 1500,                        // feedback duration in ms
  }
}

| Option | Type | Default | Description | |---|---|---|---| | buttonLabel | string | 'Copy section as Markdown' | Button tooltip and aria-label | | flashDuration | number | 1500 | How long (ms) the success/error icon stays visible |

Customization

The plugin injects its own styles, which you can override in your site's CSS. All relevant selectors:

/* Button base */
.copy-md-btn { }

/* Hover state on the button itself */
.copy-md-btn:hover { }

/* Success feedback (shown for 2 s after a successful copy) */
.copy-md-btn.copy-md-ok { }

/* Error feedback */
.copy-md-btn.copy-md-error { }

Browser support

Uses navigator.clipboard.writeText with a document.execCommand('copy') fallback for older browsers and non-HTTPS environments.

License

MIT