Skip to content

Commit

Permalink
Strip trailing whitespace (including newlines) from copy button
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrw committed Oct 3, 2023
1 parent 48c72f0 commit d634eec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion static/js/global-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function setupCodeBlockCopyButton() {
const elem = $(this).closest('.code-container').find('code').clone();
elem.find('.command-prefix').remove(); // removing prefix
elem.find('.disable-copy').remove(); // removing text which shouldn't be copied
navigator.clipboard.writeText(elem.text());
navigator.clipboard.writeText(elem.text().trim());
$(this).find('span').text('Copied!');
setTimeout(() => {
$(this).find('span').text('Copy');
Expand Down

0 comments on commit d634eec

Please sign in to comment.