fix(copy_button): compatibility with hljs newer syntax

This commit is contained in:
curben 2019-10-19 04:07:59 +01:00
parent b26dee22f5
commit eeec6b5838
No known key found for this signature in database
GPG Key ID: 5D9DB57A25D34EE3
1 changed files with 2 additions and 2 deletions

View File

@ -9,8 +9,8 @@ hexo.extend.filter.register('after_render:html', (data) => {
const copyBtn = '<button class="copy-button">Copy</button>'
// Regex is based on https://github.com/hexojs/hexo/pull/3697
return data.replace(/<td class="code">(?!<\/td>).+?<\/td>/ig, (str) => {
if (!str.includes(copyBtn)) return str.replace('</td>', copyBtn + '</td>')
return data.replace(/<pre>(?!<\/pre>).+?<\/pre>/ig, (str) => {
if (!str.includes(copyBtn)) return str.replace('</pre>', copyBtn + '</pre>')
return str
})
})