fix(theme): ignore removed diff lines while copying code

pull/1624/head
Divyansh Singh 2 years ago
parent 6bc46db4eb
commit f4d5417930

@ -14,10 +14,15 @@ export function useCopyCode() {
} }
const isShell = /language-(shellscript|shell|bash|sh|zsh)/.test( const isShell = /language-(shellscript|shell|bash|sh|zsh)/.test(
parent.classList.toString() parent.className
) )
let { innerText: text = '' } = sibling let text = ''
sibling
.querySelectorAll('span.line:not(.diff.remove)')
.forEach((node) => (text += (node.textContent || '') + '\n'))
text = text.slice(0, -1)
if (isShell) { if (isShell) {
text = text.replace(/^ *(\$|>) /gm, '').trim() text = text.replace(/^ *(\$|>) /gm, '').trim()

Loading…
Cancel
Save