taraskevizer 8.0.6 → 8.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +3 -5
- package/dist/index.cjs +20 -36
- package/dist/index.js +20 -36
- package/package.json +1 -2
package/dist/bin.js
CHANGED
|
@@ -14,7 +14,7 @@ const printWithPrefix = (msg) => {
|
|
|
14
14
|
process.argv.splice(0, 2);
|
|
15
15
|
const checkForOptions = (options) => process.argv[0] && options.includes(process.argv[0].toLowerCase());
|
|
16
16
|
if (checkForOptions(["-v", "--version"])) {
|
|
17
|
-
printWithPrefix("8.0.
|
|
17
|
+
printWithPrefix("8.0.7");
|
|
18
18
|
process.exit(0);
|
|
19
19
|
}
|
|
20
20
|
if (checkForOptions(["-h", "--help"])) {
|
|
@@ -75,8 +75,7 @@ let mode = "plainText";
|
|
|
75
75
|
const toHashTable = (dict) => {
|
|
76
76
|
const result = {};
|
|
77
77
|
for (const [options, callback] of dict)
|
|
78
|
-
for (const option of options)
|
|
79
|
-
result[option] = callback;
|
|
78
|
+
for (const option of options) result[option] = callback;
|
|
80
79
|
return result;
|
|
81
80
|
};
|
|
82
81
|
const optionDict = toHashTable([
|
|
@@ -177,8 +176,7 @@ if (process.argv.length) {
|
|
|
177
176
|
for await (const chunk of process.stdin) {
|
|
178
177
|
chunks.push(chunk);
|
|
179
178
|
length += chunk.length;
|
|
180
|
-
if (chunk.includes("\n"))
|
|
181
|
-
break;
|
|
179
|
+
if (chunk.includes("\n")) break;
|
|
182
180
|
}
|
|
183
181
|
} else {
|
|
184
182
|
for await (const chunk of process.stdin) {
|
package/dist/index.cjs
CHANGED
|
@@ -38,8 +38,7 @@ var dictFrom = {
|
|
|
38
38
|
* Adds the global flag to all patterns in the dictionary.
|
|
39
39
|
*/
|
|
40
40
|
nonGlobal: (dict) => {
|
|
41
|
-
for (const item of dict)
|
|
42
|
-
item[0] = RegExp(item[0], "g" + item[0].flags);
|
|
41
|
+
for (const item of dict) item[0] = RegExp(item[0], "g" + item[0].flags);
|
|
43
42
|
return dict;
|
|
44
43
|
}
|
|
45
44
|
};
|
|
@@ -2038,8 +2037,7 @@ var VARIATION = {
|
|
|
2038
2037
|
// src/config.ts
|
|
2039
2038
|
var TaraskConfig = class {
|
|
2040
2039
|
constructor(options) {
|
|
2041
|
-
if (!options)
|
|
2042
|
-
return;
|
|
2040
|
+
if (!options) return;
|
|
2043
2041
|
for (const [target, source] of [
|
|
2044
2042
|
[this.general, options.general],
|
|
2045
2043
|
[this.html, options.html],
|
|
@@ -2047,8 +2045,7 @@ var TaraskConfig = class {
|
|
|
2047
2045
|
]) {
|
|
2048
2046
|
if (source)
|
|
2049
2047
|
for (const [key, value] of Object.entries(source)) {
|
|
2050
|
-
if (value !== void 0)
|
|
2051
|
-
target[key] = value;
|
|
2048
|
+
if (value !== void 0) target[key] = value;
|
|
2052
2049
|
}
|
|
2053
2050
|
}
|
|
2054
2051
|
}
|
|
@@ -2073,8 +2070,7 @@ var TaraskConfig = class {
|
|
|
2073
2070
|
// src/tarask.ts
|
|
2074
2071
|
var tarask = (text, pipeline, cfg = new TaraskConfig()) => {
|
|
2075
2072
|
const options = { text, cfg, storage: {} };
|
|
2076
|
-
for (const step of pipeline)
|
|
2077
|
-
step(options);
|
|
2073
|
+
for (const step of pipeline) step(options);
|
|
2078
2074
|
return options.text;
|
|
2079
2075
|
};
|
|
2080
2076
|
|
|
@@ -2144,17 +2140,14 @@ var highlightDiff = (text, orig, isCyrillic, highlight) => {
|
|
|
2144
2140
|
for (let i = 0; i < text.length; i++) {
|
|
2145
2141
|
const word = text[i];
|
|
2146
2142
|
const oWord = orig[i];
|
|
2147
|
-
if (oWord === word)
|
|
2148
|
-
continue;
|
|
2143
|
+
if (oWord === word) continue;
|
|
2149
2144
|
const wordH = isCyrillic ? replaceGByOpposite(word) : word;
|
|
2150
|
-
if (oWord === wordH)
|
|
2151
|
-
continue;
|
|
2145
|
+
if (oWord === wordH) continue;
|
|
2152
2146
|
if (!/\(/.test(word)) {
|
|
2153
2147
|
if (word.length === oWord.length) {
|
|
2154
2148
|
const wordLetters = word.split("");
|
|
2155
2149
|
for (let j = 0; j < wordLetters.length; j++) {
|
|
2156
|
-
if (wordH[j] !== oWord[j])
|
|
2157
|
-
wordLetters[j] = highlight(wordLetters[j]);
|
|
2150
|
+
if (wordH[j] !== oWord[j]) wordLetters[j] = highlight(wordLetters[j]);
|
|
2158
2151
|
}
|
|
2159
2152
|
text[i] = wordLetters.join("");
|
|
2160
2153
|
continue;
|
|
@@ -2175,8 +2168,7 @@ var highlightDiff = (text, orig, isCyrillic, highlight) => {
|
|
|
2175
2168
|
let fromStart = 0;
|
|
2176
2169
|
let fromWordEnd = word.length - 1;
|
|
2177
2170
|
let fromOWordEnd = oWordEnd;
|
|
2178
|
-
while (wordH[fromStart] === oWord[fromStart])
|
|
2179
|
-
++fromStart;
|
|
2171
|
+
while (wordH[fromStart] === oWord[fromStart]) ++fromStart;
|
|
2180
2172
|
while (wordH[fromWordEnd] === oWord[fromOWordEnd]) {
|
|
2181
2173
|
--fromWordEnd;
|
|
2182
2174
|
--fromOWordEnd;
|
|
@@ -2186,8 +2178,7 @@ var highlightDiff = (text, orig, isCyrillic, highlight) => {
|
|
|
2186
2178
|
text[i] = highlight(word);
|
|
2187
2179
|
continue;
|
|
2188
2180
|
}
|
|
2189
|
-
if (fromWordEnd < 0)
|
|
2190
|
-
fromWordEnd = 0;
|
|
2181
|
+
if (fromWordEnd < 0) fromWordEnd = 0;
|
|
2191
2182
|
}
|
|
2192
2183
|
if (fromStart === fromWordEnd + 1) {
|
|
2193
2184
|
--fromStart;
|
|
@@ -2212,8 +2203,7 @@ var replaceWithDict = (text, dict = []) => {
|
|
|
2212
2203
|
var isUpperCase = (str) => str === str.toUpperCase();
|
|
2213
2204
|
var getLastLetter = (word, i) => {
|
|
2214
2205
|
const result = /\p{L}(?=[^\p{L}]*$)/u.exec(word);
|
|
2215
|
-
if (result)
|
|
2216
|
-
return result[0];
|
|
2206
|
+
if (result) return result[0];
|
|
2217
2207
|
throw new Error(
|
|
2218
2208
|
`the last letter of the word "${word}" not found. index: ${i}`
|
|
2219
2209
|
);
|
|
@@ -2222,14 +2212,12 @@ var restoreCase = (text, orig) => {
|
|
|
2222
2212
|
for (let i = 0; i < text.length; i++) {
|
|
2223
2213
|
const word = text[i];
|
|
2224
2214
|
const oWord = orig[i];
|
|
2225
|
-
if (word === oWord)
|
|
2226
|
-
continue;
|
|
2215
|
+
if (word === oWord) continue;
|
|
2227
2216
|
if (word === oWord.toLowerCase()) {
|
|
2228
2217
|
text[i] = oWord;
|
|
2229
2218
|
continue;
|
|
2230
2219
|
}
|
|
2231
|
-
if (!oWord[0] || !isUpperCase(oWord[0]))
|
|
2232
|
-
continue;
|
|
2220
|
+
if (!oWord[0] || !isUpperCase(oWord[0])) continue;
|
|
2233
2221
|
if (word === "зь") {
|
|
2234
2222
|
text[i] = isUpperCase(orig[i + 1]) ? "ЗЬ" : "Зь";
|
|
2235
2223
|
} else if (isUpperCase(getLastLetter(oWord, i))) {
|
|
@@ -2397,8 +2385,7 @@ var resolveSpecialSyntax = (leftAngleBracket) => mutatingStep(
|
|
|
2397
2385
|
}
|
|
2398
2386
|
) : text2;
|
|
2399
2387
|
const parts = text.split(/(?=[<>])/g);
|
|
2400
|
-
if (parts.length === 1)
|
|
2401
|
-
return escapeCapsIfNeeded(text);
|
|
2388
|
+
if (parts.length === 1) return escapeCapsIfNeeded(text);
|
|
2402
2389
|
let result = text.startsWith("<") ? "" : escapeCapsIfNeeded(parts.shift());
|
|
2403
2390
|
let depth = 0;
|
|
2404
2391
|
let currentPart = "";
|
|
@@ -2458,8 +2445,7 @@ var restoreCaseStep = ({
|
|
|
2458
2445
|
restoreCase(textArr, origArr);
|
|
2459
2446
|
} else {
|
|
2460
2447
|
for (let i = 0; i < textArr.length; i++) {
|
|
2461
|
-
if (origArr[i] !== origArr[i].toLowerCase())
|
|
2462
|
-
textArr[i] = origArr[i];
|
|
2448
|
+
if (origArr[i] !== origArr[i].toLowerCase()) textArr[i] = origArr[i];
|
|
2463
2449
|
}
|
|
2464
2450
|
}
|
|
2465
2451
|
};
|
|
@@ -2491,14 +2477,12 @@ var storeSplittedText = ({
|
|
|
2491
2477
|
var wordlistPlusNoSoften = wordlist.concat(noSoften);
|
|
2492
2478
|
var taraskevize = mutatingStep(({ text }) => {
|
|
2493
2479
|
text = replaceWithDict(text, wordlistPlusNoSoften);
|
|
2494
|
-
softening:
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
break;
|
|
2501
|
-
} while (true);
|
|
2480
|
+
softening: do {
|
|
2481
|
+
text = replaceWithDict(text, softeners);
|
|
2482
|
+
for (const [pattern, result] of softeners)
|
|
2483
|
+
if (result !== "$1дзьдз" && pattern.test(text)) continue softening;
|
|
2484
|
+
break;
|
|
2485
|
+
} while (true);
|
|
2502
2486
|
return replaceWithDict(
|
|
2503
2487
|
text.replace(//g, "").replace(/не пра/g, "не пра"),
|
|
2504
2488
|
afterTarask
|
package/dist/index.js
CHANGED
|
@@ -36,8 +36,7 @@ var dictFrom = {
|
|
|
36
36
|
* Adds the global flag to all patterns in the dictionary.
|
|
37
37
|
*/
|
|
38
38
|
nonGlobal: (dict) => {
|
|
39
|
-
for (const item of dict)
|
|
40
|
-
item[0] = RegExp(item[0], "g" + item[0].flags);
|
|
39
|
+
for (const item of dict) item[0] = RegExp(item[0], "g" + item[0].flags);
|
|
41
40
|
return dict;
|
|
42
41
|
}
|
|
43
42
|
};
|
|
@@ -2036,8 +2035,7 @@ var VARIATION = {
|
|
|
2036
2035
|
// src/config.ts
|
|
2037
2036
|
var TaraskConfig = class {
|
|
2038
2037
|
constructor(options) {
|
|
2039
|
-
if (!options)
|
|
2040
|
-
return;
|
|
2038
|
+
if (!options) return;
|
|
2041
2039
|
for (const [target, source] of [
|
|
2042
2040
|
[this.general, options.general],
|
|
2043
2041
|
[this.html, options.html],
|
|
@@ -2045,8 +2043,7 @@ var TaraskConfig = class {
|
|
|
2045
2043
|
]) {
|
|
2046
2044
|
if (source)
|
|
2047
2045
|
for (const [key, value] of Object.entries(source)) {
|
|
2048
|
-
if (value !== void 0)
|
|
2049
|
-
target[key] = value;
|
|
2046
|
+
if (value !== void 0) target[key] = value;
|
|
2050
2047
|
}
|
|
2051
2048
|
}
|
|
2052
2049
|
}
|
|
@@ -2071,8 +2068,7 @@ var TaraskConfig = class {
|
|
|
2071
2068
|
// src/tarask.ts
|
|
2072
2069
|
var tarask = (text, pipeline, cfg = new TaraskConfig()) => {
|
|
2073
2070
|
const options = { text, cfg, storage: {} };
|
|
2074
|
-
for (const step of pipeline)
|
|
2075
|
-
step(options);
|
|
2071
|
+
for (const step of pipeline) step(options);
|
|
2076
2072
|
return options.text;
|
|
2077
2073
|
};
|
|
2078
2074
|
|
|
@@ -2142,17 +2138,14 @@ var highlightDiff = (text, orig, isCyrillic, highlight) => {
|
|
|
2142
2138
|
for (let i = 0; i < text.length; i++) {
|
|
2143
2139
|
const word = text[i];
|
|
2144
2140
|
const oWord = orig[i];
|
|
2145
|
-
if (oWord === word)
|
|
2146
|
-
continue;
|
|
2141
|
+
if (oWord === word) continue;
|
|
2147
2142
|
const wordH = isCyrillic ? replaceGByOpposite(word) : word;
|
|
2148
|
-
if (oWord === wordH)
|
|
2149
|
-
continue;
|
|
2143
|
+
if (oWord === wordH) continue;
|
|
2150
2144
|
if (!/\(/.test(word)) {
|
|
2151
2145
|
if (word.length === oWord.length) {
|
|
2152
2146
|
const wordLetters = word.split("");
|
|
2153
2147
|
for (let j = 0; j < wordLetters.length; j++) {
|
|
2154
|
-
if (wordH[j] !== oWord[j])
|
|
2155
|
-
wordLetters[j] = highlight(wordLetters[j]);
|
|
2148
|
+
if (wordH[j] !== oWord[j]) wordLetters[j] = highlight(wordLetters[j]);
|
|
2156
2149
|
}
|
|
2157
2150
|
text[i] = wordLetters.join("");
|
|
2158
2151
|
continue;
|
|
@@ -2173,8 +2166,7 @@ var highlightDiff = (text, orig, isCyrillic, highlight) => {
|
|
|
2173
2166
|
let fromStart = 0;
|
|
2174
2167
|
let fromWordEnd = word.length - 1;
|
|
2175
2168
|
let fromOWordEnd = oWordEnd;
|
|
2176
|
-
while (wordH[fromStart] === oWord[fromStart])
|
|
2177
|
-
++fromStart;
|
|
2169
|
+
while (wordH[fromStart] === oWord[fromStart]) ++fromStart;
|
|
2178
2170
|
while (wordH[fromWordEnd] === oWord[fromOWordEnd]) {
|
|
2179
2171
|
--fromWordEnd;
|
|
2180
2172
|
--fromOWordEnd;
|
|
@@ -2184,8 +2176,7 @@ var highlightDiff = (text, orig, isCyrillic, highlight) => {
|
|
|
2184
2176
|
text[i] = highlight(word);
|
|
2185
2177
|
continue;
|
|
2186
2178
|
}
|
|
2187
|
-
if (fromWordEnd < 0)
|
|
2188
|
-
fromWordEnd = 0;
|
|
2179
|
+
if (fromWordEnd < 0) fromWordEnd = 0;
|
|
2189
2180
|
}
|
|
2190
2181
|
if (fromStart === fromWordEnd + 1) {
|
|
2191
2182
|
--fromStart;
|
|
@@ -2210,8 +2201,7 @@ var replaceWithDict = (text, dict = []) => {
|
|
|
2210
2201
|
var isUpperCase = (str) => str === str.toUpperCase();
|
|
2211
2202
|
var getLastLetter = (word, i) => {
|
|
2212
2203
|
const result = /\p{L}(?=[^\p{L}]*$)/u.exec(word);
|
|
2213
|
-
if (result)
|
|
2214
|
-
return result[0];
|
|
2204
|
+
if (result) return result[0];
|
|
2215
2205
|
throw new Error(
|
|
2216
2206
|
`the last letter of the word "${word}" not found. index: ${i}`
|
|
2217
2207
|
);
|
|
@@ -2220,14 +2210,12 @@ var restoreCase = (text, orig) => {
|
|
|
2220
2210
|
for (let i = 0; i < text.length; i++) {
|
|
2221
2211
|
const word = text[i];
|
|
2222
2212
|
const oWord = orig[i];
|
|
2223
|
-
if (word === oWord)
|
|
2224
|
-
continue;
|
|
2213
|
+
if (word === oWord) continue;
|
|
2225
2214
|
if (word === oWord.toLowerCase()) {
|
|
2226
2215
|
text[i] = oWord;
|
|
2227
2216
|
continue;
|
|
2228
2217
|
}
|
|
2229
|
-
if (!oWord[0] || !isUpperCase(oWord[0]))
|
|
2230
|
-
continue;
|
|
2218
|
+
if (!oWord[0] || !isUpperCase(oWord[0])) continue;
|
|
2231
2219
|
if (word === "зь") {
|
|
2232
2220
|
text[i] = isUpperCase(orig[i + 1]) ? "ЗЬ" : "Зь";
|
|
2233
2221
|
} else if (isUpperCase(getLastLetter(oWord, i))) {
|
|
@@ -2395,8 +2383,7 @@ var resolveSpecialSyntax = (leftAngleBracket) => mutatingStep(
|
|
|
2395
2383
|
}
|
|
2396
2384
|
) : text2;
|
|
2397
2385
|
const parts = text.split(/(?=[<>])/g);
|
|
2398
|
-
if (parts.length === 1)
|
|
2399
|
-
return escapeCapsIfNeeded(text);
|
|
2386
|
+
if (parts.length === 1) return escapeCapsIfNeeded(text);
|
|
2400
2387
|
let result = text.startsWith("<") ? "" : escapeCapsIfNeeded(parts.shift());
|
|
2401
2388
|
let depth = 0;
|
|
2402
2389
|
let currentPart = "";
|
|
@@ -2456,8 +2443,7 @@ var restoreCaseStep = ({
|
|
|
2456
2443
|
restoreCase(textArr, origArr);
|
|
2457
2444
|
} else {
|
|
2458
2445
|
for (let i = 0; i < textArr.length; i++) {
|
|
2459
|
-
if (origArr[i] !== origArr[i].toLowerCase())
|
|
2460
|
-
textArr[i] = origArr[i];
|
|
2446
|
+
if (origArr[i] !== origArr[i].toLowerCase()) textArr[i] = origArr[i];
|
|
2461
2447
|
}
|
|
2462
2448
|
}
|
|
2463
2449
|
};
|
|
@@ -2489,14 +2475,12 @@ var storeSplittedText = ({
|
|
|
2489
2475
|
var wordlistPlusNoSoften = wordlist.concat(noSoften);
|
|
2490
2476
|
var taraskevize = mutatingStep(({ text }) => {
|
|
2491
2477
|
text = replaceWithDict(text, wordlistPlusNoSoften);
|
|
2492
|
-
softening:
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
break;
|
|
2499
|
-
} while (true);
|
|
2478
|
+
softening: do {
|
|
2479
|
+
text = replaceWithDict(text, softeners);
|
|
2480
|
+
for (const [pattern, result] of softeners)
|
|
2481
|
+
if (result !== "$1дзьдз" && pattern.test(text)) continue softening;
|
|
2482
|
+
break;
|
|
2483
|
+
} while (true);
|
|
2500
2484
|
return replaceWithDict(
|
|
2501
2485
|
text.replace(//g, "").replace(/не пра/g, "не пра"),
|
|
2502
2486
|
afterTarask
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "taraskevizer",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.7",
|
|
4
4
|
"author": "GooseOb",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"module": "dist/index.js",
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@digitak/esrun": "^3.2.26",
|
|
13
|
-
"@types/diff": "^5.2.0",
|
|
14
13
|
"@types/node": "^20.12.7",
|
|
15
14
|
"bun-types": "^1.1.4",
|
|
16
15
|
"husky": "^9.0.11",
|