🐛 Fix: remove the leading and trailing whitespace of the code string (#205)

This commit is contained in:
Cell
2022-10-05 19:35:22 +08:00
parent 667d9c9b61
commit 5efebec3ae
4 changed files with 5 additions and 3 deletions
+1
View File
@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
> Snapshot: <>
- :bug: Fix: remove the leading and trailing whitespace of the code string ([#205](https://github.com/hugo-fixit/FixIt/issues/205))
- **Full Changelog:** @Lruihao [`v0.2.16...v0.2.17`](https://github.com/hugo-fixit/FixIt/compare/v0.2.16...v0.2.17)
## v0.2.16 [2022.9.24]
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -1
View File
@@ -498,7 +498,8 @@ class FixIt {
const $copy = document.createElement('span');
$copy.insertAdjacentHTML('afterbegin', '<i class="fa-regular fa-copy fa-fw" aria-hidden="true"></i>');
$copy.classList.add('copy');
const code = $code.innerText;
// remove the leading and trailing whitespace of the code string
const code = $code.innerText.trim();
if (this.config.code.maxShownLines < 0 || code.split('\n').length < this.config.code.maxShownLines + 2) {
$chroma.classList.add('open');
}