From eeec6b583855cc162728a3d658dd03e45e08badb Mon Sep 17 00:00:00 2001 From: curben <2809763-curben@users.noreply.gitlab.com> Date: Sat, 19 Oct 2019 04:07:59 +0100 Subject: [PATCH] fix(copy_button): compatibility with hljs newer syntax --- themes/chameleon/scripts/copy-button.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/chameleon/scripts/copy-button.js b/themes/chameleon/scripts/copy-button.js index bbf6f66..24484d4 100644 --- a/themes/chameleon/scripts/copy-button.js +++ b/themes/chameleon/scripts/copy-button.js @@ -9,8 +9,8 @@ hexo.extend.filter.register('after_render:html', (data) => { const copyBtn = '' // Regex is based on https://github.com/hexojs/hexo/pull/3697 - return data.replace(/
(?!<\/pre>).+?<\/pre>/ig, (str) => { + if (!str.includes(copyBtn)) return str.replace('', copyBtn + '') return str }) })