Skip to content

Commit

Permalink
fix: remove excess line breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabe Yuan committed Feb 26, 2024
1 parent 420e59b commit 77a37cc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/libs/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ export class Translator {
let q = el.innerText.trim();
this._tranNodes.set(el, q);
const keeps = [];
console.log("q", q);

// 保留元素
const [matchSelector, subSelector] = this._keepSelector;
Expand All @@ -462,9 +463,15 @@ export class Translator {
});

if (keeps.length > 0) {
q = text;
// textContent会保留些无用的换行符,严重影响翻译质量
if (q.includes("\n")) {
q = text;
} else {
q = text.replaceAll("\n", " ");
}
}
}
console.log("q2", q);

// 太长或太短
if (this._invalidLength(q.replace(/\[(\d+)\]/g, "").trim())) {
Expand Down

0 comments on commit 77a37cc

Please sign in to comment.