Skip to content

Commit

Permalink
- fix line break replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasMue91 committed Apr 24, 2024
1 parent 8c66dd8 commit 4cef46e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tools/gptranslator.html
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,11 @@ <h3 style="cursor: pointer;" data-target="#aboutText">About ️👆</h3>
resultsContainer.innerHTML += `<p><strong>Detected Language:</strong> ${detected_language}</p>`;
translation_options.forEach(option => {
const fittingScore = option.hasOwnProperty('fitting_score') ? ` (${option.fitting_score.toFixed(2)})` : '';
const sanitizedTranslation = option.translation.replace(/\n/g, '<br>');
resultsContainer.innerHTML += `
<p class="translation">
<strong>Translation:${fittingScore}</strong>
<span class="value" style="cursor: pointer;">${option.translation}</span>
<span class="value" style="cursor: pointer;">${sanitizedTranslation}</span>
<span class="favorite-btn" style="cursor: pointer; float: right;" title="Add to Favorites">⭐</span>
</p>
`;
Expand Down Expand Up @@ -732,9 +733,6 @@ <h3 style="cursor: pointer;" data-target="#aboutText">About ️👆</h3>
});

const fixJSON = (jsonStr) => {
// Replace newline characters from the input string.
jsonStr = jsonStr.replace(/\n/g, '<br>');

// Substitute all the backslashes from JSON string.
jsonStr = jsonStr.replace(/\\/g, '');

Expand Down

0 comments on commit 4cef46e

Please sign in to comment.