Avoid copying code line numbers

the copy code button would include line numbers, which is not good. This change removes them from the copied text by removing elements with the `.giallo-ln` class.
This commit is contained in:
aslowwriter 2026-04-29 12:09:02 +02:00 committed by GitHub
parent 17029f02b1
commit e7360f31f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,7 +27,13 @@ const copyCodeAndChangeIcon = async (copyDiv, block) => {
};
const getNonTableCode = (block) => {
return [...block.querySelectorAll('code')].map((code) => code.textContent).join('');
return [...block.querySelectorAll('code')]
.map((code) => {
const clone = code.cloneNode(true);
clone.querySelectorAll('.giallo-ln').forEach(el => el.remove());
return clone.textContent;
})
.join('');
};
const getTableCode = (block) => {