mirror of
https://github.com/adityatelange/hugo-PaperMod.git
synced 2025-05-30 06:25:24 -04:00
Add checks for adding the copy button in code-blocks
- adds checks to put copy button for code inside table and highlight code block - Fixes #363
This commit is contained in:
parent
c3634e6ccd
commit
98c17559e9
2 changed files with 14 additions and 3 deletions
|
@ -120,7 +120,17 @@
|
|||
selection.removeRange(range);
|
||||
});
|
||||
|
||||
container.appendChild(copybutton);
|
||||
if (container.classList.contains("highlight")) {
|
||||
container.appendChild(copybutton);
|
||||
} else if (container.parentNode.firstChild == container) {
|
||||
// td containing LineNos
|
||||
} else if (codeblock.parentNode.parentNode.parentNode.parentNode.parentNode.nodeName == "TABLE") {
|
||||
// table containing LineNos and code
|
||||
codeblock.parentNode.parentNode.parentNode.parentNode.parentNode.appendChild(copybutton);
|
||||
} else {
|
||||
// code blocks not having highlight as parent class
|
||||
codeblock.parentNode.appendChild(copybutton);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{{- end }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue