Skip to content

Commit

Permalink
fix(theme): ignore removed diff lines while copying code
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Nov 16, 2022
1 parent 6bc46db commit f4d5417
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/client/app/composables/copyCode.ts
Expand Up @@ -14,10 +14,15 @@ export function useCopyCode() {
}

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) {
text = text.replace(/^ *(\$|>) /gm, '').trim()
Expand Down

0 comments on commit f4d5417

Please sign in to comment.