5 * Add "Copy" button to code snippet
8 hexo.extend.filter.register('after_render:html', (data) => {
9 const copyBtn = '<button class="copy-button">Copy</button>'
11 // Regex is based on https://github.com/hexojs/hexo/pull/3697
12 return data.replace(/<pre>(?!<\/pre>).+?<\/pre>/gs, (str) => {
13 if (!str.includes(copyBtn)) return str.replace('</pre>', copyBtn + '</pre>')