Highlight.js copy button plugin.
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