Skip to content

Commit

Permalink
fix code copy for snippets of code with line numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
cydave committed Jan 1, 2024
1 parent 6dd8c05 commit 9227867
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Demo @ https://cydave.github.io/zola-theme-papermod/
+ [ ] Regular Mode
+ [ ] Home-Info Mode
+ [ ] Profile Mode
+ [ ] Code copy buttons
+ [x] Code copy buttons
+ [ ] Search page
+ [ ] SEO Metadata
+ [ ] Language switcher (multi-language support)
Expand Down
7 changes: 6 additions & 1 deletion templates/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@

copybutton.addEventListener('click', (cb) => {
if ('clipboard' in navigator) {
navigator.clipboard.writeText(codeblock.textContent);
var content = codeblock.textContent;
if(codeblock.firstChild.tagName == 'TABLE') {
content = Array(...codeblock.firstChild.getElementsByTagName('span')).map((span) => { return span.textContent; }).join('');
}
console.log(content);
navigator.clipboard.writeText(content);
copyingDone();
return;
}
Expand Down

0 comments on commit 9227867

Please sign in to comment.