From a429e0fd811ea06252ed657a38add4956b57f4b5 Mon Sep 17 00:00:00 2001 From: curben <2809763-curben@users.noreply.gitlab.com> Date: Fri, 6 Sep 2019 08:02:44 +0100 Subject: [PATCH] fix(copy-button): add button to every codeblock --- scripts/copy-button.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/copy-button.js b/scripts/copy-button.js index 0a709ca..bbf6f66 100644 --- a/scripts/copy-button.js +++ b/scripts/copy-button.js @@ -6,11 +6,11 @@ */ hexo.extend.filter.register('after_render:html', (data) => { - // Avoid duplicate button - if (data.includes('')) return; - const copyBtn = '' // Regex is based on https://github.com/hexojs/hexo/pull/3697 - return data.replace(/(?!<\/td>).+?<\/td>/, (str) => str.replace('', copyBtn + '')) + return data.replace(/(?!<\/td>).+?<\/td>/ig, (str) => { + if (!str.includes(copyBtn)) return str.replace('', copyBtn + '') + return str + }) })