Spaces:
Running
Running
字下げボタン追加
Browse files- index.html +16 -34
index.html
CHANGED
|
@@ -479,44 +479,26 @@
|
|
| 479 |
function addSpacesAfterMarks(text) {
|
| 480 |
if (!text) return '';
|
| 481 |
|
| 482 |
-
// 感嘆符・ハートマークの後に全角スペースを追加
|
| 483 |
-
// 既にスペースがある場合は重複しないよう処理
|
| 484 |
-
// ただし、行末の閉じ括弧の直前にはスペースを置かない
|
| 485 |
let processedText = text;
|
| 486 |
|
| 487 |
-
//
|
| 488 |
-
const
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
// 感嘆符・ハートマークのパターン
|
| 493 |
-
const markPattern = /([!?!?♡♥❤]+)(\s*)/g;
|
| 494 |
-
|
| 495 |
-
let processedLine = line.replace(markPattern, function(match, marks, existingSpaces) {
|
| 496 |
-
// 行末の閉じ括弧の直前かどうかをチェック
|
| 497 |
-
const afterMatch = line.substring(line.indexOf(match) + match.length);
|
| 498 |
-
const isBeforeClosingBracket = /^\s*[)」』】〕]}]/.test(afterMatch);
|
| 499 |
-
|
| 500 |
-
if (isBeforeClosingBracket) {
|
| 501 |
-
// 閉じ括弧の直前の場合はスペースを削除
|
| 502 |
-
return marks;
|
| 503 |
-
} else {
|
| 504 |
-
// 既存のスペースを全角スペースに統一
|
| 505 |
-
const normalizedSpaces = existingSpaces.replace(/[ \u00A0]/g, ' ');
|
| 506 |
-
|
| 507 |
-
// 全角スペースが既に1つ以上ある場合はそのまま、ない場合は1つ追加
|
| 508 |
-
if (normalizedSpaces.length >= 1) {
|
| 509 |
-
return marks + normalizedSpaces;
|
| 510 |
-
} else {
|
| 511 |
-
return marks + ' ';
|
| 512 |
-
}
|
| 513 |
-
}
|
| 514 |
-
});
|
| 515 |
|
| 516 |
-
|
| 517 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 518 |
|
| 519 |
-
|
|
|
|
|
|
|
|
|
|
| 520 |
}
|
| 521 |
|
| 522 |
|
|
|
|
| 479 |
function addSpacesAfterMarks(text) {
|
| 480 |
if (!text) return '';
|
| 481 |
|
|
|
|
|
|
|
|
|
|
| 482 |
let processedText = text;
|
| 483 |
|
| 484 |
+
// 1. まず感嘆符・ハートマークの後に全角スペースを追加
|
| 485 |
+
const markPattern = /([!?!?♡♥❤]+)(\s*)/g;
|
| 486 |
+
processedText = processedText.replace(markPattern, function(match, marks, existingSpaces) {
|
| 487 |
+
// 既存のスペースを全角スペースに統一
|
| 488 |
+
const normalizedSpaces = existingSpaces.replace(/[ \u00A0]/g, ' ');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 489 |
|
| 490 |
+
// 全角スペースが既に1つ以上ある場合はそのまま、ない場合は1つ追加
|
| 491 |
+
if (normalizedSpaces.length >= 1) {
|
| 492 |
+
return marks + normalizedSpaces;
|
| 493 |
+
} else {
|
| 494 |
+
return marks + ' ';
|
| 495 |
+
}
|
| 496 |
+
});
|
| 497 |
|
| 498 |
+
// 2. 閉じ括弧の直前のスペースを削除
|
| 499 |
+
processedText = processedText.replace(/[!?!?♡♥❤] +([)」』】〕]}])/g, '$1');
|
| 500 |
+
|
| 501 |
+
return processedText;
|
| 502 |
}
|
| 503 |
|
| 504 |
|