GitXplorerGitXplorer
c

copy-as-markdown

public
38 stars
5 forks
0 issues

Commits

List of commits on branch main.
Unverified
8d7818740e05ae79c39b371116c52e5ddcb8575d

Update lockfile.

ccpojer committed 8 months ago
Unverified
d100d366814059863a8359044fc12579b8418c8d

Update tests.

ccpojer committed 2 years ago
Unverified
cf02238a2496090e57ba8bd0513f14c4fb3ebd5d

Switch to pnpm, update deps.

ccpojer committed 2 years ago
Unverified
11c359d84a31eb5e33a4d571b3b2e0e5e08456d9

Update to `@nkzw` org + update React.

ccpojer committed 2 years ago
Unverified
0e4b2a648048ed4ac5157ec7aaa8df5827cbbd60

Add `processNode`, 1.2.0.

ccpojer committed 4 years ago
Unverified
e219895626dc0ff0de3ba17761fff683acc8ed71

1.1.0.

ccpojer committed 4 years ago

README

The README file for this repository.

copy-as-markdown

A React hook to copy text as Markdown.

Why?

Copying text as Markdown is helpful for blog posts or documentation pages that were authored in Markdown and may be copied into other documents or code comments. Instead of copying plain text or rich text, this utility will copy the selected content as Markdown.

Example

See it in action

Check out blog posts on cpojer.net, for example Principles of Developer Experience, and copy text within the article. The text will be copied as Markdown.

Usage

Install:

yarn add @nkzw/copy-as-markdown

Use:

import useCopyAsMarkdown from '@nkzw/copy-as-markdown';

export default function MyComponent() {
  const setRef = useCopyAsMarkdown();

  return (
    <div ref={setRef}>
      <h1>When copied, this will turn into Markdown</h1>
      Any <em>rich content</em> inside of this container will be copied as <strong>
        Markdown
      </strong>.
    </div>
  );
}

This library uses turndown to convert HTML to Markdown. You can pass any turndown Options to the useCopyAsMarkdown hook:

const setRef = useCopyAsMarkdown({
  bulletListMarker: '-',
  strongDelimiter: '__',
});