mirror of
https://github.com/lencx/ChatGPT.git
synced 2024-10-01 01:06:13 -04:00
Swapping all spaces with global   (non-blocking spaces) causes
issues with word-wrap. To solve this we now only have nbsp when we encounter spaces or a tab at the start of a line (to maintain indentation). A fiddle exists to test the regex at: https://jsfiddle.net/xtraeme/x34ao9jp/13/
This commit is contained in:
parent
66a0dafbc6
commit
f5491b4b15
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,6 +4,9 @@ node_modules/
|
|||||||
.yarn/*
|
.yarn/*
|
||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
private/
|
||||||
|
|
||||||
# rust
|
# rust
|
||||||
target/
|
target/
|
||||||
|
|
||||||
|
8
scripts/export.js
vendored
8
scripts/export.js
vendored
@ -168,7 +168,13 @@ async function exportInit() {
|
|||||||
if (replaceInUserInput) {
|
if (replaceInUserInput) {
|
||||||
const userInputBlocks = j.querySelectorAll(USER_INPUT_SELECTOR);
|
const userInputBlocks = j.querySelectorAll(USER_INPUT_SELECTOR);
|
||||||
userInputBlocks.forEach((block) => {
|
userInputBlocks.forEach((block) => {
|
||||||
block.innerHTML = block.innerHTML.replace(/\n/g, '<br/>').replace(/ /g, ' ');
|
|
||||||
|
//For quicker testing use js fiddle: https://jsfiddle.net/xtraeme/x34ao9jp/13/
|
||||||
|
block.innerHTML = block.innerHTML
|
||||||
|
.replace(/ |\u00A0/g, ' ') //Replace =C2=A0 (nbsp non-breaking space) with breaking-space
|
||||||
|
.replace(/\t/g, ' ') // Replace tab with 4 non-breaking spaces
|
||||||
|
.replace(/^ +/gm, function(match) { return ' '.repeat(match.length); }) //Add =C2=A0
|
||||||
|
.replace(/\n/g, '<br/>');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user