/highlightjs-copy-button.js

Copy button plugin for Highlight.js https://github.com/isagalaev/highlight.js

Primary LanguageJavaScriptMIT LicenseMIT

highlightjs-copy-button.js version

Highlight.js copy button plugin.

DEMO

Usage

Download plugin and include file after highlight.js:

<script src="path/to/highlight.min.js"></script>

<script src="path/to/highlightjs-copy-button.min.js"></script>

Initialize plugin after highlight.js:

hljs.initHighlightingOnLoad();

hljs.initCopyButtonOnLoad();

Here’s an equivalent way to calling initCopyButtonOnLoad using jQuery:

$(document).ready(function() {
	$('code.hljs').each(function(i, block) {
		hljs.addCopyButton(block);
	});
});

If your needs cool style, add styles by taste:

/* for block of button */
td.hljs-button {
	/* your custom style here */
}

© 2017 Sergey Mazurak | MIT License