Update test_ts.html
Browse files- test_ts.html +7 -8
test_ts.html
CHANGED
|
@@ -24,14 +24,13 @@
|
|
| 24 |
|
| 25 |
<script>
|
| 26 |
function pyEscape(s) {
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
}
|
| 35 |
|
| 36 |
document.getElementById('convert').addEventListener('click', () => {
|
| 37 |
const input = document.getElementById('ts-input').value.trim();
|
|
|
|
| 24 |
|
| 25 |
<script>
|
| 26 |
function pyEscape(s) {
|
| 27 |
+
return s
|
| 28 |
+
.replace(/\\/g, '\\\\') // экранируем обратный слеш
|
| 29 |
+
.replace(/'/g, "\\'") // экранируем одинарную кавычку
|
| 30 |
+
.replace(/\u00A0/g, '\\u00A0') // NBSP → \u00A0
|
| 31 |
+
.replace(/\r/g, '\\r') // CR → \r
|
| 32 |
+
.replace(/\n/g, '\\n'); // LF → \n (главное!)
|
| 33 |
+
}
|
|
|
|
| 34 |
|
| 35 |
document.getElementById('convert').addEventListener('click', () => {
|
| 36 |
const input = document.getElementById('ts-input').value.trim();
|