markdown-it-code-copy

0.2.1 • Public • Published

markdown-it-code-copy

npm GitHub

A markdown-it plugin to add a copy icon in code blocks to copy the code.

Screenshots

Screenshot

Installation

npm i markdown-it-code-copy

Usage

Make sure the corresponding icon font is installed (default is material-design-icons).

const md = require('markdown-it')()
	.use(require('markdown-it-code-copy'), {
		// Options
	});

Options

Name Default Description
iconStyle 'font-size: 21px; opacity: 0.4;' The style of copy icon
iconClass 'mdi mdi-content-copy' The class of copy icon
buttonStyle 'position: absolute; top: 7.5px; right: 6px; cursor: pointer; outline: none;' The style of the button wrapper
buttonClass '' The class of the button wrapper
element '' Custom HTML element as button body
onSuccess undefined Function to call when copied successfully
onError undefined Function to call when error occurred

Tips: If you want to use a different icon font, change the icon class and make sure the corresponding icon font is installed.

License

MIT License

Dependents (5)

Package Sidebar

Install

npm i markdown-it-code-copy

Weekly Downloads

1,085

Version

0.2.1

License

MIT

Unpacked Size

28.1 kB

Total Files

8

Last publish

Collaborators

  • dcsunset