mirror of https://gitlab.com/curben/blog
fix(copy_button): enable dotAll/'s' flag
- <pre> could span multiple lines
This commit is contained in:
parent
eeec6b5838
commit
ffa9c8c5be
|
@ -9,7 +9,7 @@ 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(/<pre>(?!<\/pre>).+?<\/pre>/ig, (str) => {
|
||||
return data.replace(/<pre>(?!<\/pre>).+?<\/pre>/gs, (str) => {
|
||||
if (!str.includes(copyBtn)) return str.replace('</pre>', copyBtn + '</pre>')
|
||||
return str
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue