don't copy line-remove (diff) lines

This commit is contained in:
John Bowdre 2023-11-08 22:02:57 -06:00
parent a829d12127
commit 40f9f38848

View file

@ -16,8 +16,8 @@ function createCopyButton(highlightDiv) {
document.querySelectorAll(".highlight").forEach((highlightDiv) => createCopyButton(highlightDiv)); document.querySelectorAll(".highlight").forEach((highlightDiv) => createCopyButton(highlightDiv));
async function copyCodeToClipboard(button, highlightDiv) { async function copyCodeToClipboard(button, highlightDiv) {
// capture all code lines in the selected block which aren't classed `nocopy` // capture all code lines in the selected block which aren't classed `nocopy` or `line-remove`
let codeToCopy = highlightDiv.querySelectorAll(":last-child > .torchlight > code > .line:not(.nocopy)"); let codeToCopy = highlightDiv.querySelectorAll(":last-child > .torchlight > code > .line:not(.nocopy, .line-remove)");
// now remove the first-child of each line which has class `line-number` // now remove the first-child of each line which has class `line-number`
codeToCopy = Array.from(codeToCopy).reduce((accumulator, line) => { codeToCopy = Array.from(codeToCopy).reduce((accumulator, line) => {
if (line.firstChild.className != "line-number") { if (line.firstChild.className != "line-number") {