0.0.3 • Published 5 months ago

copy-llms-txt v0.0.3

Weekly downloads
-
License
-
Repository
-
Last release
5 months ago

CopyLlmsTxt

A lightweight JavaScript library that lets you copy the content of a webpage as clean markdown with a simple keyboard shortcut.

Features

  • One-key shortcut to copy page content as markdown
  • Automatically removes navigation, ads, and other non-content elements
  • Customizable options

Installation

npm install copy-llms-txt

Basic Usage

import CopyLlmsTxt from "copy-llms-txt";

// Initialize with default options
CopyLlmsTxt.init();

// Now use Cmd+C (Mac) or Ctrl+C (Windows/Linux) to copy page content as markdown

Advanced Usage

import CopyLlmsTxt from "copy-llms-txt";

// Initialize with custom options
CopyLlmsTxt.init({
  key: "m", // Change shortcut to Cmd+M or Ctrl+M
  meta: true, // Force Meta (Cmd) key even on non-Mac
  turndownOptions: {
    // Turndown service options
    headingStyle: "atx",
    codeBlockStyle: "fenced"
  },
  selectorsToRemove: [
    // Custom selectors to remove
    ".sidebar",
    ".comments",
    "#recommendations"
  ]
});

// Manually trigger copy
document.getElementById("copyBtn").addEventListener("click", () => {
  CopyLlmsTxt.copy();
});

// Clean up when no longer needed
CopyLlmsTxt.destroy();

API Reference

init(options?)

Initializes the library with optional configuration.

Options:

  • key (string): Keyboard shortcut key. Default: 'c'
  • meta (boolean): Use Meta key (Cmd on Mac) instead of Ctrl. Default: auto-detected
  • turndownOptions (object): Options for TurndownService HTML-to-markdown conversion
  • selectorsToRemove (string[]): DOM selectors to remove before conversion

copy()

Manually copies the current page content as markdown.

destroy()

Removes event listeners and cleans up the library instance.

Credits / Dependencies

License

MIT

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago