taraskevizer 8.0.2 → 8.0.4
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 +5 -4
- package/dist/index.cjs +121 -107
- package/dist/index.d.ts +18 -9
- package/dist/index.js +121 -107
- 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.4");
|
|
18
18
|
process.exit(0);
|
|
19
19
|
}
|
|
20
20
|
if (checkForOptions(["-h", "--help"])) {
|
|
@@ -158,17 +158,18 @@ const optionDict = toHashTable([
|
|
|
158
158
|
]
|
|
159
159
|
]);
|
|
160
160
|
let currOption;
|
|
161
|
-
|
|
161
|
+
process.argv.reverse();
|
|
162
|
+
while (currOption = process.argv.pop()) {
|
|
162
163
|
if (currOption in optionDict) {
|
|
163
164
|
optionDict[currOption]();
|
|
164
165
|
} else {
|
|
165
|
-
process.argv.
|
|
166
|
+
process.argv.push(currOption);
|
|
166
167
|
break;
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
170
|
let text = "";
|
|
170
171
|
if (process.argv.length) {
|
|
171
|
-
text = process.argv.join(" ");
|
|
172
|
+
text = process.argv.reverse().join(" ");
|
|
172
173
|
} else {
|
|
173
174
|
const chunks = [];
|
|
174
175
|
let length = 0;
|
package/dist/index.cjs
CHANGED
|
@@ -2139,6 +2139,7 @@ __export(lib_exports, {
|
|
|
2139
2139
|
dictFrom: () => dictFrom,
|
|
2140
2140
|
highlightDiff: () => highlightDiff,
|
|
2141
2141
|
htmlWrappers: () => htmlWrappers,
|
|
2142
|
+
mutatingStep: () => mutatingStep,
|
|
2142
2143
|
replaceG: () => replaceG,
|
|
2143
2144
|
replaceWithDict: () => replaceWithDict,
|
|
2144
2145
|
restoreCase: () => restoreCase
|
|
@@ -2281,15 +2282,33 @@ var ansiColorWrappers = {
|
|
|
2281
2282
|
variable: (content) => `\x1B[35m${content}\x1B[0m`
|
|
2282
2283
|
};
|
|
2283
2284
|
|
|
2284
|
-
// src/
|
|
2285
|
-
var
|
|
2286
|
-
|
|
2287
|
-
options.text = replaceWithDict(replaceWithDict(options.text, lower), upper);
|
|
2288
|
-
};
|
|
2289
|
-
var convertAlphabetLowerCase = (options) => {
|
|
2290
|
-
options.text = replaceWithDict(options.text, options.cfg.general.abc.lower);
|
|
2285
|
+
// src/lib/mutating-step.ts
|
|
2286
|
+
var mutatingStep = (callback) => (options) => {
|
|
2287
|
+
options.text = callback(options);
|
|
2291
2288
|
};
|
|
2292
2289
|
|
|
2290
|
+
// src/steps/convert-alphabet.ts
|
|
2291
|
+
var convertAlphabet = mutatingStep(
|
|
2292
|
+
({
|
|
2293
|
+
text,
|
|
2294
|
+
cfg: {
|
|
2295
|
+
general: {
|
|
2296
|
+
abc: { upper, lower }
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
}) => replaceWithDict(replaceWithDict(text, lower), upper)
|
|
2300
|
+
);
|
|
2301
|
+
var convertAlphabetLowerCase = mutatingStep(
|
|
2302
|
+
({
|
|
2303
|
+
text,
|
|
2304
|
+
cfg: {
|
|
2305
|
+
general: {
|
|
2306
|
+
abc: { lower }
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
}) => replaceWithDict(text, lower)
|
|
2310
|
+
);
|
|
2311
|
+
|
|
2293
2312
|
// src/steps/highlight-diff.ts
|
|
2294
2313
|
var highlightDiffStep = (highlight) => ({
|
|
2295
2314
|
cfg: {
|
|
@@ -2327,9 +2346,9 @@ var replaceIbyJ = (options) => {
|
|
|
2327
2346
|
};
|
|
2328
2347
|
|
|
2329
2348
|
// src/steps/join-splitted.ts
|
|
2330
|
-
var joinSplittedText = (
|
|
2331
|
-
|
|
2332
|
-
|
|
2349
|
+
var joinSplittedText = mutatingStep(
|
|
2350
|
+
({ storage: { textArr } }) => textArr.join(" ")
|
|
2351
|
+
);
|
|
2333
2352
|
|
|
2334
2353
|
// src/steps/apply-g.ts
|
|
2335
2354
|
var applyGHtml = (options) => {
|
|
@@ -2354,12 +2373,9 @@ var applyGNonHtml = (options) => {
|
|
|
2354
2373
|
};
|
|
2355
2374
|
|
|
2356
2375
|
// src/steps/apply-variations.ts
|
|
2357
|
-
var applyVariableParts = (callback) => (
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
($0) => callback($0.slice(1, -1).split("|"))
|
|
2361
|
-
);
|
|
2362
|
-
};
|
|
2376
|
+
var applyVariableParts = (callback) => mutatingStep(
|
|
2377
|
+
({ text }) => text.replace(/\([^)]*?\)/g, ($0) => callback($0.slice(1, -1).split("|")))
|
|
2378
|
+
);
|
|
2363
2379
|
var applyVariationsHtml = applyVariableParts((parts) => {
|
|
2364
2380
|
const main = parts.shift();
|
|
2365
2381
|
return `<tarL data-l='${parts}'>${main}</tarL>`;
|
|
@@ -2374,89 +2390,90 @@ var applyVariationsNonHtml = (options) => {
|
|
|
2374
2390
|
};
|
|
2375
2391
|
|
|
2376
2392
|
// src/steps/prepare.ts
|
|
2377
|
-
var prepare = (
|
|
2378
|
-
|
|
2379
|
-
|
|
2393
|
+
var prepare = mutatingStep(
|
|
2394
|
+
({ text }) => text.replace(/г'(?![еёіюя])/g, "ґ").replace(/ - /g, " — ").replace(new RegExp("(\\p{P}|\\p{S}|\\d+)", "gu"), " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "(")
|
|
2395
|
+
);
|
|
2380
2396
|
|
|
2381
2397
|
// src/steps/resolve-syntax.ts
|
|
2382
2398
|
var NOFIX_CHAR = " ";
|
|
2383
2399
|
var NOFIX_REGEX = new RegExp(NOFIX_CHAR, "g");
|
|
2384
2400
|
var applyNoFix = (options) => {
|
|
2385
2401
|
const { noFixArr } = options.storage;
|
|
2386
|
-
if (noFixArr.length)
|
|
2387
|
-
|
|
2402
|
+
if (noFixArr.length) {
|
|
2403
|
+
noFixArr.reverse();
|
|
2404
|
+
options.text = options.text.replace(NOFIX_REGEX, () => noFixArr.pop());
|
|
2405
|
+
}
|
|
2388
2406
|
};
|
|
2389
|
-
var resolveSpecialSyntax = (leftAngleBracket) => (
|
|
2390
|
-
|
|
2407
|
+
var resolveSpecialSyntax = (leftAngleBracket) => mutatingStep(
|
|
2408
|
+
({
|
|
2391
2409
|
text,
|
|
2392
2410
|
storage,
|
|
2393
2411
|
cfg: {
|
|
2394
2412
|
general: { doEscapeCapitalized, abc }
|
|
2395
2413
|
}
|
|
2396
|
-
}
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
if (part.startsWith("<")) {
|
|
2419
|
-
++depth;
|
|
2420
|
-
currentPart += part;
|
|
2421
|
-
} else if (depth) {
|
|
2422
|
-
--depth;
|
|
2423
|
-
if (depth) {
|
|
2414
|
+
}) => {
|
|
2415
|
+
const noFixArr = storage.noFixArr = [];
|
|
2416
|
+
const convertAlphavet = (abcOnlyText, abc2) => restoreCase(
|
|
2417
|
+
replaceWithDict(abcOnlyText.toLowerCase(), abc2.lower).split(" "),
|
|
2418
|
+
abcOnlyText.split(" ")
|
|
2419
|
+
).join(" ");
|
|
2420
|
+
const escapeCapsIfNeeded = (text2) => doEscapeCapitalized ? text2.replace(
|
|
2421
|
+
new RegExp("(?!<=\\p{Lu} )\\p{Lu}{2}[\\p{Lu} ]*(?!= \\p{Lu})", "gu"),
|
|
2422
|
+
($0) => {
|
|
2423
|
+
noFixArr.push(convertAlphavet($0, abc));
|
|
2424
|
+
return NOFIX_CHAR;
|
|
2425
|
+
}
|
|
2426
|
+
) : text2;
|
|
2427
|
+
const parts = text.split(/(?=[<>])/g);
|
|
2428
|
+
if (parts.length === 1)
|
|
2429
|
+
return escapeCapsIfNeeded(text);
|
|
2430
|
+
let result = text.startsWith("<") ? "" : escapeCapsIfNeeded(parts.shift());
|
|
2431
|
+
let depth = 0;
|
|
2432
|
+
let currentPart = "";
|
|
2433
|
+
for (const part of parts) {
|
|
2434
|
+
if (part.startsWith("<")) {
|
|
2435
|
+
++depth;
|
|
2424
2436
|
currentPart += part;
|
|
2425
|
-
} else {
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
char = currentPart[2];
|
|
2430
|
-
currentPart = convertAlphavet(
|
|
2431
|
-
currentPart.slice(char === "," || char === "." ? 3 : 2),
|
|
2432
|
-
abc
|
|
2433
|
-
);
|
|
2437
|
+
} else if (depth) {
|
|
2438
|
+
--depth;
|
|
2439
|
+
if (depth) {
|
|
2440
|
+
currentPart += part;
|
|
2434
2441
|
} else {
|
|
2435
|
-
char =
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2442
|
+
let char = "";
|
|
2443
|
+
const isAbc = currentPart[1] === "*";
|
|
2444
|
+
if (isAbc) {
|
|
2445
|
+
char = currentPart[2];
|
|
2446
|
+
currentPart = convertAlphavet(
|
|
2447
|
+
currentPart.slice(char === "," || char === "." ? 3 : 2),
|
|
2448
|
+
abc
|
|
2449
|
+
);
|
|
2450
|
+
} else {
|
|
2451
|
+
char = currentPart[1];
|
|
2452
|
+
currentPart = currentPart.slice(2);
|
|
2453
|
+
}
|
|
2454
|
+
let toAddToResult;
|
|
2455
|
+
switch (char) {
|
|
2456
|
+
case ".":
|
|
2457
|
+
toAddToResult = NOFIX_CHAR;
|
|
2458
|
+
noFixArr.push(currentPart);
|
|
2459
|
+
break;
|
|
2460
|
+
case ",":
|
|
2461
|
+
toAddToResult = leftAngleBracket + currentPart + ">";
|
|
2462
|
+
break;
|
|
2463
|
+
default:
|
|
2464
|
+
toAddToResult = leftAngleBracket + NOFIX_CHAR;
|
|
2465
|
+
noFixArr.push((isAbc ? "" : char) + currentPart + ">");
|
|
2466
|
+
}
|
|
2467
|
+
result += toAddToResult + escapeCapsIfNeeded(part.slice(1));
|
|
2468
|
+
currentPart = "";
|
|
2450
2469
|
}
|
|
2451
|
-
|
|
2452
|
-
|
|
2470
|
+
} else {
|
|
2471
|
+
result += escapeCapsIfNeeded(part);
|
|
2453
2472
|
}
|
|
2454
|
-
} else {
|
|
2455
|
-
result += escapeCapsIfNeeded(part);
|
|
2456
2473
|
}
|
|
2474
|
+
return result + escapeCapsIfNeeded(currentPart);
|
|
2457
2475
|
}
|
|
2458
|
-
|
|
2459
|
-
};
|
|
2476
|
+
);
|
|
2460
2477
|
|
|
2461
2478
|
// src/steps/restore-case.ts
|
|
2462
2479
|
var restoreCaseStep = ({
|
|
@@ -2500,8 +2517,7 @@ var storeSplittedText = ({
|
|
|
2500
2517
|
|
|
2501
2518
|
// src/steps/taraskevize.ts
|
|
2502
2519
|
var wordlistPlusNoSoften = wordlist.concat(noSoften);
|
|
2503
|
-
var taraskevize = (
|
|
2504
|
-
let { text } = options;
|
|
2520
|
+
var taraskevize = mutatingStep(({ text }) => {
|
|
2505
2521
|
text = replaceWithDict(text, wordlistPlusNoSoften);
|
|
2506
2522
|
softening:
|
|
2507
2523
|
do {
|
|
@@ -2511,41 +2527,39 @@ var taraskevize = (options) => {
|
|
|
2511
2527
|
continue softening;
|
|
2512
2528
|
break;
|
|
2513
2529
|
} while (true);
|
|
2514
|
-
|
|
2530
|
+
return replaceWithDict(
|
|
2515
2531
|
text.replace(//g, "").replace(/не пра/g, "не пра"),
|
|
2516
2532
|
afterTarask
|
|
2517
2533
|
).replace(/не пра/g, "не пра");
|
|
2518
|
-
};
|
|
2534
|
+
});
|
|
2519
2535
|
|
|
2520
2536
|
// src/steps/whitespaces.ts
|
|
2521
|
-
var whitespacesToSpaces = (
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
}
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
spaces
|
|
2532
|
-
|
|
2533
|
-
|
|
2537
|
+
var whitespacesToSpaces = mutatingStep(
|
|
2538
|
+
({ text, storage }) => {
|
|
2539
|
+
storage.spaces = [];
|
|
2540
|
+
return text.replace(/\s+/g, (match) => {
|
|
2541
|
+
storage.spaces.push(match);
|
|
2542
|
+
return " ";
|
|
2543
|
+
});
|
|
2544
|
+
}
|
|
2545
|
+
);
|
|
2546
|
+
var restoreWhitespaces = mutatingStep(
|
|
2547
|
+
({ text, storage: { spaces } }) => {
|
|
2548
|
+
spaces.reverse();
|
|
2549
|
+
return text.replace(/ /g, () => spaces.pop());
|
|
2550
|
+
}
|
|
2551
|
+
);
|
|
2534
2552
|
|
|
2535
2553
|
// src/steps/trim.ts
|
|
2536
|
-
var trim = (
|
|
2537
|
-
options.text = ` ${options.text.trim()} `;
|
|
2538
|
-
};
|
|
2554
|
+
var trim = mutatingStep(({ text }) => ` ${text.trim()} `);
|
|
2539
2555
|
|
|
2540
2556
|
// src/steps/finalize.ts
|
|
2541
|
-
var finalize = (newLine) => (
|
|
2542
|
-
|
|
2543
|
-
|
|
2557
|
+
var finalize = (newLine) => mutatingStep(
|
|
2558
|
+
({ text }) => text.replace(/(/g, "(").replace(/ /g, " ").replace(new RegExp(" (\\p{P}|\\p{S}|\\d+) ", "gu"), "$1").replace(/\n/g, newLine).trim()
|
|
2559
|
+
);
|
|
2544
2560
|
|
|
2545
2561
|
// src/steps/to-lower-case.ts
|
|
2546
|
-
var toLowerCase = (
|
|
2547
|
-
options.text = options.text.toLowerCase();
|
|
2548
|
-
};
|
|
2562
|
+
var toLowerCase = mutatingStep(({ text }) => text.toLowerCase());
|
|
2549
2563
|
|
|
2550
2564
|
// src/pipelines.ts
|
|
2551
2565
|
var pipelines_exports = {};
|
package/dist/index.d.ts
CHANGED
|
@@ -175,7 +175,7 @@ declare class TaraskConfig {
|
|
|
175
175
|
nonHtml: NonHtmlOptions;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
type TaraskStep<Storage = {}> = (args: {
|
|
178
|
+
type TaraskStep<Storage extends object = {}> = (args: {
|
|
179
179
|
text: string;
|
|
180
180
|
storage: Storage;
|
|
181
181
|
cfg: TaraskConfig;
|
|
@@ -185,8 +185,8 @@ type SplittedTextStorage = {
|
|
|
185
185
|
origArr: readonly string[];
|
|
186
186
|
};
|
|
187
187
|
|
|
188
|
-
declare const convertAlphabet: TaraskStep
|
|
189
|
-
declare const convertAlphabetLowerCase: TaraskStep
|
|
188
|
+
declare const convertAlphabet: TaraskStep<{}>;
|
|
189
|
+
declare const convertAlphabetLowerCase: TaraskStep<{}>;
|
|
190
190
|
|
|
191
191
|
/**
|
|
192
192
|
* Uses {@link highlightDiff}
|
|
@@ -233,7 +233,7 @@ declare const applyVariationsNonHtml: TaraskStep;
|
|
|
233
233
|
*
|
|
234
234
|
* Some changes should be reverted in the {@link finalize} step.
|
|
235
235
|
*/
|
|
236
|
-
declare const prepare: TaraskStep
|
|
236
|
+
declare const prepare: TaraskStep<{}>;
|
|
237
237
|
|
|
238
238
|
/**
|
|
239
239
|
* Created in {@link resolveSpecialSyntax}.
|
|
@@ -265,7 +265,7 @@ declare const storeSplittedAbcConvertedOrig: TaraskStep<SplittedTextStorage>;
|
|
|
265
265
|
|
|
266
266
|
declare const storeSplittedText: TaraskStep<SplittedTextStorage>;
|
|
267
267
|
|
|
268
|
-
declare const taraskevize: TaraskStep
|
|
268
|
+
declare const taraskevize: TaraskStep<{}>;
|
|
269
269
|
|
|
270
270
|
/**
|
|
271
271
|
* Created in {@link whitespacesToSpaces}.
|
|
@@ -288,7 +288,7 @@ declare const whitespacesToSpaces: TaraskStep<WhiteSpaceStorage>;
|
|
|
288
288
|
*/
|
|
289
289
|
declare const restoreWhitespaces: TaraskStep<WhiteSpaceStorage>;
|
|
290
290
|
|
|
291
|
-
declare const trim: TaraskStep
|
|
291
|
+
declare const trim: TaraskStep<{}>;
|
|
292
292
|
|
|
293
293
|
/**
|
|
294
294
|
* @param newLine - The string to replace new lines with.
|
|
@@ -304,7 +304,7 @@ declare const trim: TaraskStep;
|
|
|
304
304
|
*/
|
|
305
305
|
declare const finalize: (newLine: string) => TaraskStep;
|
|
306
306
|
|
|
307
|
-
declare const toLowerCase: TaraskStep
|
|
307
|
+
declare const toLowerCase: TaraskStep<{}>;
|
|
308
308
|
|
|
309
309
|
/**
|
|
310
310
|
* This module exports all the steps
|
|
@@ -321,7 +321,7 @@ declare const toLowerCase: TaraskStep;
|
|
|
321
321
|
|
|
322
322
|
type index$1_SpecialSyntaxStorage = SpecialSyntaxStorage;
|
|
323
323
|
type index$1_SplittedTextStorage = SplittedTextStorage;
|
|
324
|
-
type index$1_TaraskStep<Storage = {}> = TaraskStep<Storage>;
|
|
324
|
+
type index$1_TaraskStep<Storage extends object = {}> = TaraskStep<Storage>;
|
|
325
325
|
type index$1_WhiteSpaceStorage = WhiteSpaceStorage;
|
|
326
326
|
declare const index$1_applyGHtml: typeof applyGHtml;
|
|
327
327
|
declare const index$1_applyGNonHtml: typeof applyGNonHtml;
|
|
@@ -421,6 +421,14 @@ declare const ansiColorWrappers: {
|
|
|
421
421
|
variable: (content: string) => string;
|
|
422
422
|
};
|
|
423
423
|
|
|
424
|
+
/**
|
|
425
|
+
* An abstraction for a step that always changes the text.
|
|
426
|
+
*
|
|
427
|
+
* > Not recommended to use if
|
|
428
|
+
* a step doesn't ALWAYS change the text.
|
|
429
|
+
*/
|
|
430
|
+
declare const mutatingStep: <T extends object = {}>(callback: (...args: Parameters<TaraskStep<T>>) => string) => TaraskStep<T>;
|
|
431
|
+
|
|
424
432
|
/**
|
|
425
433
|
* Collection of functions that help to work with dictionaries.
|
|
426
434
|
*/
|
|
@@ -438,11 +446,12 @@ declare const index_ansiColorWrappers: typeof ansiColorWrappers;
|
|
|
438
446
|
declare const index_dictFrom: typeof dictFrom;
|
|
439
447
|
declare const index_highlightDiff: typeof highlightDiff;
|
|
440
448
|
declare const index_htmlWrappers: typeof htmlWrappers;
|
|
449
|
+
declare const index_mutatingStep: typeof mutatingStep;
|
|
441
450
|
declare const index_replaceG: typeof replaceG;
|
|
442
451
|
declare const index_replaceWithDict: typeof replaceWithDict;
|
|
443
452
|
declare const index_restoreCase: typeof restoreCase;
|
|
444
453
|
declare namespace index {
|
|
445
|
-
export { type index_ExtendedDict as ExtendedDict, index_afterTarask as afterTarask, index_ansiColorWrappers as ansiColorWrappers, index_dictFrom as dictFrom, index_highlightDiff as highlightDiff, index_htmlWrappers as htmlWrappers, index_replaceG as replaceG, index_replaceWithDict as replaceWithDict, index_restoreCase as restoreCase };
|
|
454
|
+
export { type index_ExtendedDict as ExtendedDict, index_afterTarask as afterTarask, index_ansiColorWrappers as ansiColorWrappers, index_dictFrom as dictFrom, index_highlightDiff as highlightDiff, index_htmlWrappers as htmlWrappers, index_mutatingStep as mutatingStep, index_replaceG as replaceG, index_replaceWithDict as replaceWithDict, index_restoreCase as restoreCase };
|
|
446
455
|
}
|
|
447
456
|
|
|
448
457
|
export { type HtmlOptions, type NonHtmlOptions, REPLACE_J, TaraskConfig, type TaraskOptions, VARIATION, index$3 as dicts, index as lib, pipelines, index$1 as steps, tarask };
|
package/dist/index.js
CHANGED
|
@@ -2112,6 +2112,7 @@ __export(lib_exports, {
|
|
|
2112
2112
|
dictFrom: () => dictFrom,
|
|
2113
2113
|
highlightDiff: () => highlightDiff,
|
|
2114
2114
|
htmlWrappers: () => htmlWrappers,
|
|
2115
|
+
mutatingStep: () => mutatingStep,
|
|
2115
2116
|
replaceG: () => replaceG,
|
|
2116
2117
|
replaceWithDict: () => replaceWithDict,
|
|
2117
2118
|
restoreCase: () => restoreCase
|
|
@@ -2254,15 +2255,33 @@ var ansiColorWrappers = {
|
|
|
2254
2255
|
variable: (content) => `\x1B[35m${content}\x1B[0m`
|
|
2255
2256
|
};
|
|
2256
2257
|
|
|
2257
|
-
// src/
|
|
2258
|
-
var
|
|
2259
|
-
|
|
2260
|
-
options.text = replaceWithDict(replaceWithDict(options.text, lower), upper);
|
|
2261
|
-
};
|
|
2262
|
-
var convertAlphabetLowerCase = (options) => {
|
|
2263
|
-
options.text = replaceWithDict(options.text, options.cfg.general.abc.lower);
|
|
2258
|
+
// src/lib/mutating-step.ts
|
|
2259
|
+
var mutatingStep = (callback) => (options) => {
|
|
2260
|
+
options.text = callback(options);
|
|
2264
2261
|
};
|
|
2265
2262
|
|
|
2263
|
+
// src/steps/convert-alphabet.ts
|
|
2264
|
+
var convertAlphabet = mutatingStep(
|
|
2265
|
+
({
|
|
2266
|
+
text,
|
|
2267
|
+
cfg: {
|
|
2268
|
+
general: {
|
|
2269
|
+
abc: { upper, lower }
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
}) => replaceWithDict(replaceWithDict(text, lower), upper)
|
|
2273
|
+
);
|
|
2274
|
+
var convertAlphabetLowerCase = mutatingStep(
|
|
2275
|
+
({
|
|
2276
|
+
text,
|
|
2277
|
+
cfg: {
|
|
2278
|
+
general: {
|
|
2279
|
+
abc: { lower }
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
}) => replaceWithDict(text, lower)
|
|
2283
|
+
);
|
|
2284
|
+
|
|
2266
2285
|
// src/steps/highlight-diff.ts
|
|
2267
2286
|
var highlightDiffStep = (highlight) => ({
|
|
2268
2287
|
cfg: {
|
|
@@ -2300,9 +2319,9 @@ var replaceIbyJ = (options) => {
|
|
|
2300
2319
|
};
|
|
2301
2320
|
|
|
2302
2321
|
// src/steps/join-splitted.ts
|
|
2303
|
-
var joinSplittedText = (
|
|
2304
|
-
|
|
2305
|
-
|
|
2322
|
+
var joinSplittedText = mutatingStep(
|
|
2323
|
+
({ storage: { textArr } }) => textArr.join(" ")
|
|
2324
|
+
);
|
|
2306
2325
|
|
|
2307
2326
|
// src/steps/apply-g.ts
|
|
2308
2327
|
var applyGHtml = (options) => {
|
|
@@ -2327,12 +2346,9 @@ var applyGNonHtml = (options) => {
|
|
|
2327
2346
|
};
|
|
2328
2347
|
|
|
2329
2348
|
// src/steps/apply-variations.ts
|
|
2330
|
-
var applyVariableParts = (callback) => (
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
($0) => callback($0.slice(1, -1).split("|"))
|
|
2334
|
-
);
|
|
2335
|
-
};
|
|
2349
|
+
var applyVariableParts = (callback) => mutatingStep(
|
|
2350
|
+
({ text }) => text.replace(/\([^)]*?\)/g, ($0) => callback($0.slice(1, -1).split("|")))
|
|
2351
|
+
);
|
|
2336
2352
|
var applyVariationsHtml = applyVariableParts((parts) => {
|
|
2337
2353
|
const main = parts.shift();
|
|
2338
2354
|
return `<tarL data-l='${parts}'>${main}</tarL>`;
|
|
@@ -2347,89 +2363,90 @@ var applyVariationsNonHtml = (options) => {
|
|
|
2347
2363
|
};
|
|
2348
2364
|
|
|
2349
2365
|
// src/steps/prepare.ts
|
|
2350
|
-
var prepare = (
|
|
2351
|
-
|
|
2352
|
-
|
|
2366
|
+
var prepare = mutatingStep(
|
|
2367
|
+
({ text }) => text.replace(/г'(?![еёіюя])/g, "ґ").replace(/ - /g, " — ").replace(new RegExp("(\\p{P}|\\p{S}|\\d+)", "gu"), " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "(")
|
|
2368
|
+
);
|
|
2353
2369
|
|
|
2354
2370
|
// src/steps/resolve-syntax.ts
|
|
2355
2371
|
var NOFIX_CHAR = " ";
|
|
2356
2372
|
var NOFIX_REGEX = new RegExp(NOFIX_CHAR, "g");
|
|
2357
2373
|
var applyNoFix = (options) => {
|
|
2358
2374
|
const { noFixArr } = options.storage;
|
|
2359
|
-
if (noFixArr.length)
|
|
2360
|
-
|
|
2375
|
+
if (noFixArr.length) {
|
|
2376
|
+
noFixArr.reverse();
|
|
2377
|
+
options.text = options.text.replace(NOFIX_REGEX, () => noFixArr.pop());
|
|
2378
|
+
}
|
|
2361
2379
|
};
|
|
2362
|
-
var resolveSpecialSyntax = (leftAngleBracket) => (
|
|
2363
|
-
|
|
2380
|
+
var resolveSpecialSyntax = (leftAngleBracket) => mutatingStep(
|
|
2381
|
+
({
|
|
2364
2382
|
text,
|
|
2365
2383
|
storage,
|
|
2366
2384
|
cfg: {
|
|
2367
2385
|
general: { doEscapeCapitalized, abc }
|
|
2368
2386
|
}
|
|
2369
|
-
}
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
if (part.startsWith("<")) {
|
|
2392
|
-
++depth;
|
|
2393
|
-
currentPart += part;
|
|
2394
|
-
} else if (depth) {
|
|
2395
|
-
--depth;
|
|
2396
|
-
if (depth) {
|
|
2387
|
+
}) => {
|
|
2388
|
+
const noFixArr = storage.noFixArr = [];
|
|
2389
|
+
const convertAlphavet = (abcOnlyText, abc2) => restoreCase(
|
|
2390
|
+
replaceWithDict(abcOnlyText.toLowerCase(), abc2.lower).split(" "),
|
|
2391
|
+
abcOnlyText.split(" ")
|
|
2392
|
+
).join(" ");
|
|
2393
|
+
const escapeCapsIfNeeded = (text2) => doEscapeCapitalized ? text2.replace(
|
|
2394
|
+
new RegExp("(?!<=\\p{Lu} )\\p{Lu}{2}[\\p{Lu} ]*(?!= \\p{Lu})", "gu"),
|
|
2395
|
+
($0) => {
|
|
2396
|
+
noFixArr.push(convertAlphavet($0, abc));
|
|
2397
|
+
return NOFIX_CHAR;
|
|
2398
|
+
}
|
|
2399
|
+
) : text2;
|
|
2400
|
+
const parts = text.split(/(?=[<>])/g);
|
|
2401
|
+
if (parts.length === 1)
|
|
2402
|
+
return escapeCapsIfNeeded(text);
|
|
2403
|
+
let result = text.startsWith("<") ? "" : escapeCapsIfNeeded(parts.shift());
|
|
2404
|
+
let depth = 0;
|
|
2405
|
+
let currentPart = "";
|
|
2406
|
+
for (const part of parts) {
|
|
2407
|
+
if (part.startsWith("<")) {
|
|
2408
|
+
++depth;
|
|
2397
2409
|
currentPart += part;
|
|
2398
|
-
} else {
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
char = currentPart[2];
|
|
2403
|
-
currentPart = convertAlphavet(
|
|
2404
|
-
currentPart.slice(char === "," || char === "." ? 3 : 2),
|
|
2405
|
-
abc
|
|
2406
|
-
);
|
|
2410
|
+
} else if (depth) {
|
|
2411
|
+
--depth;
|
|
2412
|
+
if (depth) {
|
|
2413
|
+
currentPart += part;
|
|
2407
2414
|
} else {
|
|
2408
|
-
char =
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2415
|
+
let char = "";
|
|
2416
|
+
const isAbc = currentPart[1] === "*";
|
|
2417
|
+
if (isAbc) {
|
|
2418
|
+
char = currentPart[2];
|
|
2419
|
+
currentPart = convertAlphavet(
|
|
2420
|
+
currentPart.slice(char === "," || char === "." ? 3 : 2),
|
|
2421
|
+
abc
|
|
2422
|
+
);
|
|
2423
|
+
} else {
|
|
2424
|
+
char = currentPart[1];
|
|
2425
|
+
currentPart = currentPart.slice(2);
|
|
2426
|
+
}
|
|
2427
|
+
let toAddToResult;
|
|
2428
|
+
switch (char) {
|
|
2429
|
+
case ".":
|
|
2430
|
+
toAddToResult = NOFIX_CHAR;
|
|
2431
|
+
noFixArr.push(currentPart);
|
|
2432
|
+
break;
|
|
2433
|
+
case ",":
|
|
2434
|
+
toAddToResult = leftAngleBracket + currentPart + ">";
|
|
2435
|
+
break;
|
|
2436
|
+
default:
|
|
2437
|
+
toAddToResult = leftAngleBracket + NOFIX_CHAR;
|
|
2438
|
+
noFixArr.push((isAbc ? "" : char) + currentPart + ">");
|
|
2439
|
+
}
|
|
2440
|
+
result += toAddToResult + escapeCapsIfNeeded(part.slice(1));
|
|
2441
|
+
currentPart = "";
|
|
2423
2442
|
}
|
|
2424
|
-
|
|
2425
|
-
|
|
2443
|
+
} else {
|
|
2444
|
+
result += escapeCapsIfNeeded(part);
|
|
2426
2445
|
}
|
|
2427
|
-
} else {
|
|
2428
|
-
result += escapeCapsIfNeeded(part);
|
|
2429
2446
|
}
|
|
2447
|
+
return result + escapeCapsIfNeeded(currentPart);
|
|
2430
2448
|
}
|
|
2431
|
-
|
|
2432
|
-
};
|
|
2449
|
+
);
|
|
2433
2450
|
|
|
2434
2451
|
// src/steps/restore-case.ts
|
|
2435
2452
|
var restoreCaseStep = ({
|
|
@@ -2473,8 +2490,7 @@ var storeSplittedText = ({
|
|
|
2473
2490
|
|
|
2474
2491
|
// src/steps/taraskevize.ts
|
|
2475
2492
|
var wordlistPlusNoSoften = wordlist.concat(noSoften);
|
|
2476
|
-
var taraskevize = (
|
|
2477
|
-
let { text } = options;
|
|
2493
|
+
var taraskevize = mutatingStep(({ text }) => {
|
|
2478
2494
|
text = replaceWithDict(text, wordlistPlusNoSoften);
|
|
2479
2495
|
softening:
|
|
2480
2496
|
do {
|
|
@@ -2484,41 +2500,39 @@ var taraskevize = (options) => {
|
|
|
2484
2500
|
continue softening;
|
|
2485
2501
|
break;
|
|
2486
2502
|
} while (true);
|
|
2487
|
-
|
|
2503
|
+
return replaceWithDict(
|
|
2488
2504
|
text.replace(//g, "").replace(/не пра/g, "не пра"),
|
|
2489
2505
|
afterTarask
|
|
2490
2506
|
).replace(/не пра/g, "не пра");
|
|
2491
|
-
};
|
|
2507
|
+
});
|
|
2492
2508
|
|
|
2493
2509
|
// src/steps/whitespaces.ts
|
|
2494
|
-
var whitespacesToSpaces = (
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
}
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
spaces
|
|
2505
|
-
|
|
2506
|
-
|
|
2510
|
+
var whitespacesToSpaces = mutatingStep(
|
|
2511
|
+
({ text, storage }) => {
|
|
2512
|
+
storage.spaces = [];
|
|
2513
|
+
return text.replace(/\s+/g, (match) => {
|
|
2514
|
+
storage.spaces.push(match);
|
|
2515
|
+
return " ";
|
|
2516
|
+
});
|
|
2517
|
+
}
|
|
2518
|
+
);
|
|
2519
|
+
var restoreWhitespaces = mutatingStep(
|
|
2520
|
+
({ text, storage: { spaces } }) => {
|
|
2521
|
+
spaces.reverse();
|
|
2522
|
+
return text.replace(/ /g, () => spaces.pop());
|
|
2523
|
+
}
|
|
2524
|
+
);
|
|
2507
2525
|
|
|
2508
2526
|
// src/steps/trim.ts
|
|
2509
|
-
var trim = (
|
|
2510
|
-
options.text = ` ${options.text.trim()} `;
|
|
2511
|
-
};
|
|
2527
|
+
var trim = mutatingStep(({ text }) => ` ${text.trim()} `);
|
|
2512
2528
|
|
|
2513
2529
|
// src/steps/finalize.ts
|
|
2514
|
-
var finalize = (newLine) => (
|
|
2515
|
-
|
|
2516
|
-
|
|
2530
|
+
var finalize = (newLine) => mutatingStep(
|
|
2531
|
+
({ text }) => text.replace(/(/g, "(").replace(/ /g, " ").replace(new RegExp(" (\\p{P}|\\p{S}|\\d+) ", "gu"), "$1").replace(/\n/g, newLine).trim()
|
|
2532
|
+
);
|
|
2517
2533
|
|
|
2518
2534
|
// src/steps/to-lower-case.ts
|
|
2519
|
-
var toLowerCase = (
|
|
2520
|
-
options.text = options.text.toLowerCase();
|
|
2521
|
-
};
|
|
2535
|
+
var toLowerCase = mutatingStep(({ text }) => text.toLowerCase());
|
|
2522
2536
|
|
|
2523
2537
|
// src/pipelines.ts
|
|
2524
2538
|
var pipelines_exports = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "taraskevizer",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.4",
|
|
4
4
|
"author": "GooseOb",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
"test": "esrun --send-code-mode=temporaryFile test",
|
|
50
50
|
"test-cli": "bun run build && esrun --send-code-mode=temporaryFile test",
|
|
51
51
|
"postinstall": "husky",
|
|
52
|
-
"typecheck": "tsc --project src/tsconfig.json",
|
|
53
52
|
"docs": "typedoc --out docs src/index.ts --skipErrorChecking"
|
|
54
53
|
},
|
|
55
54
|
"sideEffects": false,
|