taraskevizer 7.1.2 → 8.0.0
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/README.md +1 -93
- package/dist/bin.js +5 -12
- package/dist/index.cjs +194 -142
- package/dist/index.d.ts +295 -109
- package/dist/index.js +193 -139
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -68,99 +68,7 @@ tarask('яна і іншыя', abcOnlyPipeline, latinWithJiCfg);
|
|
|
68
68
|
// "jana j jinšyja"
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
how to create your own will come soon.
|
|
73
|
-
|
|
74
|
-
# Options
|
|
75
|
-
|
|
76
|
-
## general
|
|
77
|
-
|
|
78
|
-
Type: `object`
|
|
79
|
-
|
|
80
|
-
### abc
|
|
81
|
-
|
|
82
|
-
Type: `object` with schema: `{lower: Dict, upper?: Dict}`,
|
|
83
|
-
where `Dict` is `[pattern: RegExp, result: string][]`
|
|
84
|
-
(may be empty)
|
|
85
|
-
|
|
86
|
-
`alphabets` contains the following pre-defined alphabets:
|
|
87
|
-
`cyrillic`, `latin`, `latinJi`, `arabic`
|
|
88
|
-
|
|
89
|
-
Default value: `alphabets.cyrillic`
|
|
90
|
-
|
|
91
|
-
### j
|
|
92
|
-
|
|
93
|
-
Type: `number`
|
|
94
|
-
|
|
95
|
-
Default value: `0`
|
|
96
|
-
|
|
97
|
-
| Value | When to replace `і`(`i`) by `й`(`j`) after vowels | Example |
|
|
98
|
-
| ----- | ------------------------------------------------- | ------------------------ |
|
|
99
|
-
| | | `яна і ён` |
|
|
100
|
-
| 0 | never | `яна і ён` |
|
|
101
|
-
| 1 | random | `яна і ён` or `яна й ён` |
|
|
102
|
-
| 2 | always | `яна й ён` |
|
|
103
|
-
|
|
104
|
-
Has no effect with `LATIN_JI` alphabet.
|
|
105
|
-
|
|
106
|
-
### doEscapeCapitalized
|
|
107
|
-
|
|
108
|
-
Type: `boolean`
|
|
109
|
-
|
|
110
|
-
Default `true`
|
|
111
|
-
|
|
112
|
-
If set to false, may cause unwanted changes in acronyms.
|
|
113
|
-
|
|
114
|
-
Is always `false` in `abcOnlyPipeline`.
|
|
115
|
-
|
|
116
|
-
## html
|
|
117
|
-
|
|
118
|
-
### g
|
|
119
|
-
|
|
120
|
-
Type: `boolean`
|
|
121
|
-
|
|
122
|
-
Default value: `false`
|
|
123
|
-
|
|
124
|
-
Do replace `г`(`h`) by `ґ`(`g`) in cyrillic alphabet?
|
|
125
|
-
|
|
126
|
-
| Value | Example |
|
|
127
|
-
| ----- | --------------------------------------- |
|
|
128
|
-
| true | `<tarH>г</tarH>валт <tarH>Г</tarH>валт` |
|
|
129
|
-
| false | `<tarH>ґ</tarH>валт <tarH>Ґ</tarH>валт` |
|
|
130
|
-
|
|
131
|
-
## nonHtml
|
|
132
|
-
|
|
133
|
-
### ansiColors
|
|
134
|
-
|
|
135
|
-
Type: `boolean`
|
|
136
|
-
|
|
137
|
-
Default value: `false`
|
|
138
|
-
|
|
139
|
-
### h
|
|
140
|
-
|
|
141
|
-
Type: `boolean`
|
|
142
|
-
|
|
143
|
-
Default value: `false`
|
|
144
|
-
|
|
145
|
-
Do replace ґ(g) by г(h) in cyrillic alphabet?
|
|
146
|
-
|
|
147
|
-
| Value | Example |
|
|
148
|
-
| ----- | ----------- |
|
|
149
|
-
| true | Ґвалт ґвалт |
|
|
150
|
-
| false | Гвалт гвалт |
|
|
151
|
-
|
|
152
|
-
### variations
|
|
153
|
-
|
|
154
|
-
Type: `number`
|
|
155
|
-
|
|
156
|
-
Default value: `0`
|
|
157
|
-
|
|
158
|
-
| Value | Which variation is used if a part of word is variable | Example |
|
|
159
|
-
| ----- | ----------------------------------------------------- | ----------------- |
|
|
160
|
-
| | | Гродна |
|
|
161
|
-
| 0 | main | Гродна |
|
|
162
|
-
| 1 | first | Горадня |
|
|
163
|
-
| 2 | all | (Гродна\|Горадня) |
|
|
71
|
+
# [Full API documentation](https://gooseob.github.io/taraskevizer/)
|
|
164
72
|
|
|
165
73
|
# HTML tags
|
|
166
74
|
|
package/dist/bin.js
CHANGED
|
@@ -5,9 +5,7 @@ import {
|
|
|
5
5
|
VARIATION,
|
|
6
6
|
TaraskConfig,
|
|
7
7
|
tarask,
|
|
8
|
-
|
|
9
|
-
htmlPipeline,
|
|
10
|
-
plainTextPipeline
|
|
8
|
+
pipelines
|
|
11
9
|
} from "./index.js";
|
|
12
10
|
const prefix = "\x1B[34m[taraskevizer]\x1B[0m ";
|
|
13
11
|
const printWithPrefix = (msg) => {
|
|
@@ -16,7 +14,7 @@ const printWithPrefix = (msg) => {
|
|
|
16
14
|
process.argv.splice(0, 2);
|
|
17
15
|
const checkForOptions = (options) => process.argv[0] && options.includes(process.argv[0].toLowerCase());
|
|
18
16
|
if (checkForOptions(["-v", "--version"])) {
|
|
19
|
-
printWithPrefix("
|
|
17
|
+
printWithPrefix("8.0.0");
|
|
20
18
|
process.exit(0);
|
|
21
19
|
}
|
|
22
20
|
if (checkForOptions(["-h", "--help"])) {
|
|
@@ -74,7 +72,7 @@ const nonHtml = {
|
|
|
74
72
|
ansiColors: true
|
|
75
73
|
};
|
|
76
74
|
const html = { g: true };
|
|
77
|
-
let mode = "
|
|
75
|
+
let mode = "plainText";
|
|
78
76
|
const toHashTable = (dict) => {
|
|
79
77
|
const result = {};
|
|
80
78
|
for (const [options, callback] of dict)
|
|
@@ -155,7 +153,7 @@ const optionDict = toHashTable([
|
|
|
155
153
|
[
|
|
156
154
|
["--alphabet-only", "-abc"],
|
|
157
155
|
() => {
|
|
158
|
-
mode = "
|
|
156
|
+
mode = "abcOnly";
|
|
159
157
|
}
|
|
160
158
|
]
|
|
161
159
|
]);
|
|
@@ -191,12 +189,7 @@ if (process.argv.length) {
|
|
|
191
189
|
text = Buffer.concat(chunks, length).toString();
|
|
192
190
|
}
|
|
193
191
|
const cfg = new TaraskConfig({ general, html, nonHtml });
|
|
194
|
-
|
|
195
|
-
nonHtml: plainTextPipeline,
|
|
196
|
-
html: htmlPipeline,
|
|
197
|
-
alphabetOnly: abcOnlyPipeline
|
|
198
|
-
};
|
|
199
|
-
if (process.stdout.write(tarask(text, piplineByMode[mode], cfg) + "\n")) {
|
|
192
|
+
if (process.stdout.write(tarask(text, pipelines[mode], cfg) + "\n")) {
|
|
200
193
|
process.exit(0);
|
|
201
194
|
} else {
|
|
202
195
|
process.stdout.once("drain", () => {
|
package/dist/index.cjs
CHANGED
|
@@ -23,11 +23,9 @@ __export(src_exports, {
|
|
|
23
23
|
REPLACE_J: () => REPLACE_J,
|
|
24
24
|
TaraskConfig: () => TaraskConfig,
|
|
25
25
|
VARIATION: () => VARIATION,
|
|
26
|
-
abcOnlyPipeline: () => abcOnlyPipeline,
|
|
27
26
|
dicts: () => dict_exports,
|
|
28
|
-
htmlPipeline: () => htmlPipeline,
|
|
29
27
|
lib: () => lib_exports,
|
|
30
|
-
|
|
28
|
+
pipelines: () => pipelines_exports,
|
|
31
29
|
steps: () => steps_exports,
|
|
32
30
|
tarask: () => tarask
|
|
33
31
|
});
|
|
@@ -61,6 +59,9 @@ var dictFrom = {
|
|
|
61
59
|
);
|
|
62
60
|
return dict;
|
|
63
61
|
},
|
|
62
|
+
/**
|
|
63
|
+
* Adds the global flag to all patterns in the dictionary.
|
|
64
|
+
*/
|
|
64
65
|
nonGlobal: (dict) => {
|
|
65
66
|
for (const item of dict)
|
|
66
67
|
item[0] = RegExp(item[0], "g" + item[0].flags);
|
|
@@ -2047,6 +2048,18 @@ var arabic = {
|
|
|
2047
2048
|
)
|
|
2048
2049
|
};
|
|
2049
2050
|
|
|
2051
|
+
// src/constants.ts
|
|
2052
|
+
var REPLACE_J = {
|
|
2053
|
+
NEVER: 0,
|
|
2054
|
+
RANDOM: 1,
|
|
2055
|
+
ALWAYS: 2
|
|
2056
|
+
};
|
|
2057
|
+
var VARIATION = {
|
|
2058
|
+
NO: 0,
|
|
2059
|
+
FIRST: 1,
|
|
2060
|
+
ALL: 2
|
|
2061
|
+
};
|
|
2062
|
+
|
|
2050
2063
|
// src/config.ts
|
|
2051
2064
|
var TaraskConfig = class {
|
|
2052
2065
|
constructor(options) {
|
|
@@ -2064,59 +2077,58 @@ var TaraskConfig = class {
|
|
|
2064
2077
|
}
|
|
2065
2078
|
}
|
|
2066
2079
|
}
|
|
2080
|
+
/** @see {@link TaraskOptions} */
|
|
2067
2081
|
general = {
|
|
2068
2082
|
abc: alphabets_exports.cyrillic,
|
|
2069
2083
|
j: REPLACE_J.NEVER,
|
|
2070
2084
|
doEscapeCapitalized: true
|
|
2071
2085
|
};
|
|
2086
|
+
/** @see {@link HtmlOptions} */
|
|
2072
2087
|
html = {
|
|
2073
2088
|
g: false
|
|
2074
2089
|
};
|
|
2090
|
+
/** @see {@link NonHtmlOptions} */
|
|
2075
2091
|
nonHtml = {
|
|
2076
2092
|
h: false,
|
|
2077
2093
|
ansiColors: false,
|
|
2078
2094
|
variations: VARIATION.ALL
|
|
2079
2095
|
};
|
|
2080
2096
|
};
|
|
2081
|
-
var REPLACE_J = {
|
|
2082
|
-
NEVER: 0,
|
|
2083
|
-
RANDOM: 1,
|
|
2084
|
-
ALWAYS: 2
|
|
2085
|
-
};
|
|
2086
|
-
var VARIATION = {
|
|
2087
|
-
NO: 0,
|
|
2088
|
-
FIRST: 1,
|
|
2089
|
-
ALL: 2
|
|
2090
|
-
};
|
|
2091
2097
|
|
|
2092
2098
|
// src/tarask.ts
|
|
2093
2099
|
var tarask = (text, pipeline, cfg = new TaraskConfig()) => {
|
|
2094
|
-
const options = { cfg, storage: {} };
|
|
2095
|
-
|
|
2100
|
+
const options = { text, cfg, storage: {} };
|
|
2101
|
+
for (const step of pipeline)
|
|
2102
|
+
step(options);
|
|
2103
|
+
return options.text;
|
|
2096
2104
|
};
|
|
2097
2105
|
|
|
2098
2106
|
// src/steps/index.ts
|
|
2099
2107
|
var steps_exports = {};
|
|
2100
2108
|
__export(steps_exports, {
|
|
2101
|
-
|
|
2102
|
-
|
|
2109
|
+
afterJoin: () => afterJoin,
|
|
2110
|
+
applyGHtml: () => applyGHtml,
|
|
2111
|
+
applyGNonHtml: () => applyGNonHtml,
|
|
2103
2112
|
applyNoFix: () => applyNoFix,
|
|
2104
|
-
applyNonHtmlG: () => applyNonHtmlG,
|
|
2105
|
-
applyNonHtmlVariations: () => applyNonHtmlVariations,
|
|
2106
2113
|
applyVariableParts: () => applyVariableParts,
|
|
2114
|
+
applyVariationsHtml: () => applyVariationsHtml,
|
|
2115
|
+
applyVariationsNonHtml: () => applyVariationsNonHtml,
|
|
2107
2116
|
convertAlphabet: () => convertAlphabet,
|
|
2108
2117
|
convertAlphabetLowerCase: () => convertAlphabetLowerCase,
|
|
2109
|
-
|
|
2118
|
+
finalize: () => finalize,
|
|
2110
2119
|
highlightDiffStep: () => highlightDiffStep,
|
|
2120
|
+
highlightDiffStepNonHtml: () => highlightDiffStepNonHtml,
|
|
2111
2121
|
joinSplittedText: () => joinSplittedText,
|
|
2112
2122
|
prepare: () => prepare,
|
|
2113
2123
|
replaceIbyJ: () => replaceIbyJ,
|
|
2114
2124
|
resolveSpecialSyntax: () => resolveSpecialSyntax,
|
|
2115
2125
|
restoreCaseStep: () => restoreCaseStep,
|
|
2126
|
+
restoreParentheses: () => restoreParentheses,
|
|
2116
2127
|
restoreWhitespaces: () => restoreWhitespaces,
|
|
2117
2128
|
storeSplittedAbcConvertedOrig: () => storeSplittedAbcConvertedOrig,
|
|
2118
2129
|
storeSplittedText: () => storeSplittedText,
|
|
2119
2130
|
taraskevize: () => taraskevize,
|
|
2131
|
+
toLowerCase: () => toLowerCase,
|
|
2120
2132
|
trim: () => trim,
|
|
2121
2133
|
whitespacesToSpaces: () => whitespacesToSpaces
|
|
2122
2134
|
});
|
|
@@ -2272,55 +2284,118 @@ var ansiColorWrappers = {
|
|
|
2272
2284
|
};
|
|
2273
2285
|
|
|
2274
2286
|
// src/steps/convert-alphabet.ts
|
|
2275
|
-
var convertAlphabet = (
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
general: { abc }
|
|
2283
|
-
}
|
|
2284
|
-
}) => replaceWithDict(text, abc.lower);
|
|
2287
|
+
var convertAlphabet = (options) => {
|
|
2288
|
+
const { lower, upper } = options.cfg.general.abc;
|
|
2289
|
+
options.text = replaceWithDict(replaceWithDict(options.text, lower), upper);
|
|
2290
|
+
};
|
|
2291
|
+
var convertAlphabetLowerCase = (options) => {
|
|
2292
|
+
options.text = replaceWithDict(options.text, options.cfg.general.abc.lower);
|
|
2293
|
+
};
|
|
2285
2294
|
|
|
2286
2295
|
// src/steps/highlight-diff.ts
|
|
2287
|
-
var highlightDiffStep = (highlight) => (
|
|
2296
|
+
var highlightDiffStep = (highlight) => ({
|
|
2288
2297
|
cfg: {
|
|
2289
2298
|
general: { abc }
|
|
2290
2299
|
},
|
|
2291
|
-
storage: {
|
|
2300
|
+
storage: { textArr, origArr }
|
|
2292
2301
|
}) => {
|
|
2293
|
-
highlightDiff(
|
|
2294
|
-
return _;
|
|
2302
|
+
highlightDiff(textArr, origArr, abc === alphabets_exports.cyrillic, highlight);
|
|
2295
2303
|
};
|
|
2296
|
-
var
|
|
2304
|
+
var highlightDiffStepNonHtml = ({
|
|
2297
2305
|
cfg: {
|
|
2298
2306
|
general: { abc },
|
|
2299
2307
|
nonHtml: { ansiColors }
|
|
2300
2308
|
},
|
|
2301
|
-
storage: {
|
|
2309
|
+
storage: { textArr, origArr }
|
|
2302
2310
|
}) => {
|
|
2303
2311
|
if (ansiColors)
|
|
2304
2312
|
highlightDiff(
|
|
2305
|
-
|
|
2306
|
-
|
|
2313
|
+
textArr,
|
|
2314
|
+
origArr,
|
|
2307
2315
|
abc === alphabets_exports.cyrillic,
|
|
2308
2316
|
ansiColorWrappers.fix
|
|
2309
2317
|
);
|
|
2310
|
-
|
|
2318
|
+
};
|
|
2319
|
+
|
|
2320
|
+
// src/steps/i-to-j.ts
|
|
2321
|
+
var toJ = (shortU) => "й " + (shortU ? "у" : "");
|
|
2322
|
+
var replaceIbyJ = (options) => {
|
|
2323
|
+
const { abc, j } = options.cfg.general;
|
|
2324
|
+
if (j && abc !== alphabets_exports.latinJi)
|
|
2325
|
+
options.text = options.text.replace(
|
|
2326
|
+
/(?<=[аеёіоуыэюя] )і (ў?)/g,
|
|
2327
|
+
j === REPLACE_J.ALWAYS ? ($0, $1) => toJ($1) : ($0, $1) => Math.random() >= 0.5 ? toJ($1) : $0
|
|
2328
|
+
);
|
|
2329
|
+
};
|
|
2330
|
+
|
|
2331
|
+
// src/steps/join-splitted.ts
|
|
2332
|
+
var joinSplittedText = (options) => {
|
|
2333
|
+
options.text = options.storage.textArr.join(" ");
|
|
2334
|
+
};
|
|
2335
|
+
|
|
2336
|
+
// src/steps/apply-g.ts
|
|
2337
|
+
var applyGHtml = (options) => {
|
|
2338
|
+
const colorize = htmlWrappers.letterH;
|
|
2339
|
+
if (options.cfg.general.abc === alphabets_exports.cyrillic)
|
|
2340
|
+
options.text = replaceG(
|
|
2341
|
+
options.cfg.html.g ? colorize("$&") : ($0) => colorize(gobj[$0])
|
|
2342
|
+
)(options.text);
|
|
2343
|
+
};
|
|
2344
|
+
var applyGNonHtml = (options) => {
|
|
2345
|
+
const colorize = ansiColorWrappers.variable;
|
|
2346
|
+
const {
|
|
2347
|
+
cfg: {
|
|
2348
|
+
general: { abc },
|
|
2349
|
+
nonHtml: { h, ansiColors }
|
|
2350
|
+
}
|
|
2351
|
+
} = options;
|
|
2352
|
+
if (abc === alphabets_exports.cyrillic && (h || ansiColors))
|
|
2353
|
+
options.text = replaceG(
|
|
2354
|
+
ansiColors ? h ? ($0) => colorize(gobj[$0]) : colorize("$&") : ($0) => gobj[$0]
|
|
2355
|
+
)(options.text);
|
|
2356
|
+
};
|
|
2357
|
+
|
|
2358
|
+
// src/steps/apply-variations.ts
|
|
2359
|
+
var applyVariableParts = (callback) => (options) => {
|
|
2360
|
+
options.text = options.text.replace(
|
|
2361
|
+
/\([^)]*?\)/g,
|
|
2362
|
+
($0) => callback($0.slice(1, -1).split("|"))
|
|
2363
|
+
);
|
|
2364
|
+
};
|
|
2365
|
+
var applyVariationsHtml = applyVariableParts((parts) => {
|
|
2366
|
+
const main = parts.shift();
|
|
2367
|
+
return `<tarL data-l='${parts}'>${main}</tarL>`;
|
|
2368
|
+
});
|
|
2369
|
+
var applyVariationsNonHtml = (options) => {
|
|
2370
|
+
const partIndex = options.cfg.nonHtml.variations;
|
|
2371
|
+
const colorize = ansiColorWrappers.variable;
|
|
2372
|
+
if (partIndex !== VARIATION.ALL)
|
|
2373
|
+
applyVariableParts(
|
|
2374
|
+
options.cfg.nonHtml.ansiColors ? (parts) => colorize(parts[partIndex]) : (parts) => parts[partIndex]
|
|
2375
|
+
)(options);
|
|
2376
|
+
};
|
|
2377
|
+
|
|
2378
|
+
// src/steps/prepare.ts
|
|
2379
|
+
var prepare = (options) => {
|
|
2380
|
+
options.text = options.text.replace(/г'(?![еёіюя])/g, "ґ").replace(/ - /g, " — ").replace(new RegExp("(\\p{P}|\\p{S}|\\d+)", "gu"), " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "(");
|
|
2311
2381
|
};
|
|
2312
2382
|
|
|
2313
2383
|
// src/steps/resolve-syntax.ts
|
|
2314
2384
|
var NOFIX_CHAR = " ";
|
|
2315
2385
|
var NOFIX_REGEX = new RegExp(NOFIX_CHAR, "g");
|
|
2316
|
-
var applyNoFix = (
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2386
|
+
var applyNoFix = (options) => {
|
|
2387
|
+
const { noFixArr } = options.storage;
|
|
2388
|
+
if (noFixArr.length)
|
|
2389
|
+
options.text = options.text.replace(NOFIX_REGEX, () => noFixArr.shift());
|
|
2390
|
+
};
|
|
2391
|
+
var resolveSpecialSyntax = (leftAngleBracket) => (options) => {
|
|
2392
|
+
const {
|
|
2393
|
+
text,
|
|
2394
|
+
storage,
|
|
2395
|
+
cfg: {
|
|
2396
|
+
general: { doEscapeCapitalized, abc }
|
|
2397
|
+
}
|
|
2398
|
+
} = options;
|
|
2324
2399
|
const noFixArr = storage.noFixArr = [];
|
|
2325
2400
|
const convertAlphavet = (abcOnlyText, abc2) => restoreCase(
|
|
2326
2401
|
replaceWithDict(abcOnlyText.toLowerCase(), abc2.lower).split(" "),
|
|
@@ -2334,8 +2409,10 @@ var resolveSpecialSyntax = (leftAngleBracket) => (text, {
|
|
|
2334
2409
|
}
|
|
2335
2410
|
) : text2;
|
|
2336
2411
|
const parts = text.split(/(?=[<>])/g);
|
|
2337
|
-
if (parts.length === 1)
|
|
2338
|
-
|
|
2412
|
+
if (parts.length === 1) {
|
|
2413
|
+
options.text = escapeCapsIfNeeded(text);
|
|
2414
|
+
return;
|
|
2415
|
+
}
|
|
2339
2416
|
let result = text.startsWith("<") ? "" : escapeCapsIfNeeded(parts.shift());
|
|
2340
2417
|
let depth = 0;
|
|
2341
2418
|
let currentPart = "";
|
|
@@ -2380,94 +2457,53 @@ var resolveSpecialSyntax = (leftAngleBracket) => (text, {
|
|
|
2380
2457
|
result += escapeCapsIfNeeded(part);
|
|
2381
2458
|
}
|
|
2382
2459
|
}
|
|
2383
|
-
|
|
2384
|
-
};
|
|
2385
|
-
|
|
2386
|
-
// src/steps/html-steps.ts
|
|
2387
|
-
var applyHtmlVariations = applyVariableParts((parts) => {
|
|
2388
|
-
const main = parts.shift();
|
|
2389
|
-
return `<tarL data-l='${parts}'>${main}</tarL>`;
|
|
2390
|
-
});
|
|
2391
|
-
var applyHtmlG = (text, {
|
|
2392
|
-
cfg: {
|
|
2393
|
-
general: { abc },
|
|
2394
|
-
html: { g }
|
|
2395
|
-
}
|
|
2396
|
-
}) => {
|
|
2397
|
-
const colorize = htmlWrappers.letterH;
|
|
2398
|
-
return abc === alphabets_exports.cyrillic ? replaceG(g ? colorize("$&") : ($0) => colorize(gobj[$0]))(text) : text;
|
|
2399
|
-
};
|
|
2400
|
-
|
|
2401
|
-
// src/steps/i-to-j.ts
|
|
2402
|
-
var toJ = (shortU) => "й " + (shortU ? "у" : "");
|
|
2403
|
-
var replaceIbyJ = (text, {
|
|
2404
|
-
cfg: {
|
|
2405
|
-
general: { j, abc }
|
|
2406
|
-
}
|
|
2407
|
-
}) => j && abc !== alphabets_exports.latinJi ? text.replace(
|
|
2408
|
-
/(?<=[аеёіоуыэюя] )і (ў?)/g,
|
|
2409
|
-
j === REPLACE_J.ALWAYS ? ($0, $1) => toJ($1) : ($0, $1) => Math.random() >= 0.5 ? toJ($1) : $0
|
|
2410
|
-
) : text;
|
|
2411
|
-
|
|
2412
|
-
// src/steps/join-splitted.ts
|
|
2413
|
-
var joinSplittedText = (_, { storage: { text } }) => text.join(" ");
|
|
2414
|
-
|
|
2415
|
-
// src/steps/non-html-steps.ts
|
|
2416
|
-
var applyNonHtmlVariations = (text, options) => {
|
|
2417
|
-
const partIndex = options.cfg.nonHtml.variations;
|
|
2418
|
-
const colorize = ansiColorWrappers.variable;
|
|
2419
|
-
return partIndex === VARIATION.ALL ? text : applyVariableParts(
|
|
2420
|
-
options.cfg.nonHtml.ansiColors ? (parts) => colorize(parts[partIndex]) : (parts) => parts[partIndex]
|
|
2421
|
-
)(text, options);
|
|
2422
|
-
};
|
|
2423
|
-
var applyNonHtmlG = (text, {
|
|
2424
|
-
cfg: {
|
|
2425
|
-
general: { abc },
|
|
2426
|
-
nonHtml: { h, ansiColors }
|
|
2427
|
-
}
|
|
2428
|
-
}) => {
|
|
2429
|
-
const colorize = ansiColorWrappers.variable;
|
|
2430
|
-
return abc === alphabets_exports.cyrillic && (h || ansiColors) ? replaceG(
|
|
2431
|
-
ansiColors ? h ? ($0) => colorize(gobj[$0]) : colorize("$&") : ($0) => gobj[$0]
|
|
2432
|
-
)(text) : text;
|
|
2460
|
+
options.text = result + escapeCapsIfNeeded(currentPart);
|
|
2433
2461
|
};
|
|
2434
2462
|
|
|
2435
|
-
// src/steps/prepare.ts
|
|
2436
|
-
var prepare = (text) => text.replace(/г'(?![еёіюя])/g, "ґ").replace(/ - /g, " — ").replace(new RegExp("(\\p{P}|\\p{S}|\\d+)", "gu"), " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "(");
|
|
2437
|
-
|
|
2438
2463
|
// src/steps/restore-case.ts
|
|
2439
|
-
var restoreCaseStep = (
|
|
2464
|
+
var restoreCaseStep = ({
|
|
2440
2465
|
cfg: {
|
|
2441
2466
|
general: { abc }
|
|
2442
2467
|
},
|
|
2443
|
-
storage: {
|
|
2468
|
+
storage: { textArr, origArr }
|
|
2444
2469
|
}) => {
|
|
2445
2470
|
if (abc.upper) {
|
|
2446
|
-
restoreCase(
|
|
2471
|
+
restoreCase(textArr, origArr);
|
|
2447
2472
|
} else {
|
|
2448
|
-
for (let i = 0; i <
|
|
2449
|
-
if (
|
|
2450
|
-
|
|
2473
|
+
for (let i = 0; i < textArr.length; i++) {
|
|
2474
|
+
if (origArr[i] !== origArr[i].toLowerCase())
|
|
2475
|
+
textArr[i] = origArr[i];
|
|
2451
2476
|
}
|
|
2452
2477
|
}
|
|
2453
|
-
return _;
|
|
2454
2478
|
};
|
|
2455
2479
|
|
|
2456
2480
|
// src/steps/store-splitted-abc-converted-orig.ts
|
|
2457
|
-
var storeSplittedAbcConvertedOrig = (
|
|
2458
|
-
|
|
2459
|
-
|
|
2481
|
+
var storeSplittedAbcConvertedOrig = ({
|
|
2482
|
+
cfg: {
|
|
2483
|
+
general: {
|
|
2484
|
+
abc: { lower, upper }
|
|
2485
|
+
}
|
|
2486
|
+
},
|
|
2487
|
+
text,
|
|
2488
|
+
storage
|
|
2489
|
+
}) => {
|
|
2490
|
+
storage.origArr = replaceWithDict(replaceWithDict(text, lower), upper).split(
|
|
2491
|
+
" "
|
|
2492
|
+
);
|
|
2460
2493
|
};
|
|
2461
2494
|
|
|
2462
2495
|
// src/steps/store-splitted-text.ts
|
|
2463
|
-
var storeSplittedText = (
|
|
2464
|
-
|
|
2465
|
-
|
|
2496
|
+
var storeSplittedText = ({
|
|
2497
|
+
text,
|
|
2498
|
+
storage
|
|
2499
|
+
}) => {
|
|
2500
|
+
storage.textArr = text.split(" ");
|
|
2466
2501
|
};
|
|
2467
2502
|
|
|
2468
2503
|
// src/steps/taraskevize.ts
|
|
2469
2504
|
var wordlistPlusNoSoften = wordlist.concat(noSoften);
|
|
2470
|
-
var taraskevize = (
|
|
2505
|
+
var taraskevize = (options) => {
|
|
2506
|
+
let { text } = options;
|
|
2471
2507
|
text = replaceWithDict(text, wordlistPlusNoSoften);
|
|
2472
2508
|
softening:
|
|
2473
2509
|
do {
|
|
@@ -2477,37 +2513,56 @@ var taraskevize = (text) => {
|
|
|
2477
2513
|
continue softening;
|
|
2478
2514
|
break;
|
|
2479
2515
|
} while (true);
|
|
2480
|
-
|
|
2516
|
+
options.text = replaceWithDict(text.replace(//g, ""), afterTarask);
|
|
2481
2517
|
};
|
|
2482
2518
|
|
|
2483
2519
|
// src/steps/whitespaces.ts
|
|
2484
|
-
var whitespacesToSpaces = (
|
|
2520
|
+
var whitespacesToSpaces = (options) => {
|
|
2521
|
+
const { storage } = options;
|
|
2485
2522
|
storage.spaces = [];
|
|
2486
|
-
|
|
2523
|
+
options.text = options.text.replace(/\s+/g, (match) => {
|
|
2487
2524
|
storage.spaces.push(match);
|
|
2488
2525
|
return " ";
|
|
2489
2526
|
});
|
|
2490
2527
|
};
|
|
2491
|
-
var restoreWhitespaces = (
|
|
2492
|
-
|
|
2493
|
-
|
|
2528
|
+
var restoreWhitespaces = (options) => {
|
|
2529
|
+
const { spaces } = options.storage;
|
|
2530
|
+
spaces.reverse();
|
|
2531
|
+
options.text = options.text.replace(/ /g, () => spaces.pop());
|
|
2494
2532
|
};
|
|
2495
2533
|
|
|
2496
2534
|
// src/steps/trim.ts
|
|
2497
|
-
var trim = (
|
|
2535
|
+
var trim = (options) => {
|
|
2536
|
+
options.text = ` ${options.text.trim()} `;
|
|
2537
|
+
};
|
|
2538
|
+
|
|
2539
|
+
// src/steps/other.ts
|
|
2540
|
+
var restoreParentheses = (options) => {
|
|
2541
|
+
options.text = options.text.replace(/(/g, "(");
|
|
2542
|
+
};
|
|
2543
|
+
var afterJoin = (options) => {
|
|
2544
|
+
options.text = options.text.replace(/ /g, " ").replace(new RegExp(" (\\p{P}|\\p{S}|\\d+|() ", "gu"), "$1");
|
|
2545
|
+
};
|
|
2546
|
+
var finalize = (newLine) => (options) => {
|
|
2547
|
+
options.text = options.text.replace(/\n/g, newLine).trim();
|
|
2548
|
+
};
|
|
2549
|
+
var toLowerCase = (options) => {
|
|
2550
|
+
options.text = options.text.toLowerCase();
|
|
2551
|
+
};
|
|
2498
2552
|
|
|
2499
2553
|
// src/pipelines.ts
|
|
2500
|
-
var
|
|
2501
|
-
|
|
2502
|
-
|
|
2554
|
+
var pipelines_exports = {};
|
|
2555
|
+
__export(pipelines_exports, {
|
|
2556
|
+
abcOnly: () => abcOnly,
|
|
2557
|
+
html: () => html,
|
|
2558
|
+
plainText: () => plainText
|
|
2559
|
+
});
|
|
2503
2560
|
var resolveSpecialSyntaxWithLAB = resolveSpecialSyntax("<");
|
|
2504
|
-
var toLowerCase = (text) => text.toLowerCase();
|
|
2505
2561
|
var finalizeWithNewLine = finalize("\n");
|
|
2506
|
-
var
|
|
2507
|
-
(
|
|
2562
|
+
var abcOnly = [
|
|
2563
|
+
({ storage, cfg: { general } }) => {
|
|
2508
2564
|
storage.doEscapeCapitalized = general.doEscapeCapitalized;
|
|
2509
2565
|
general.doEscapeCapitalized = false;
|
|
2510
|
-
return _;
|
|
2511
2566
|
},
|
|
2512
2567
|
trim,
|
|
2513
2568
|
resolveSpecialSyntaxWithLAB,
|
|
@@ -2519,9 +2574,8 @@ var abcOnlyPipeline = [
|
|
|
2519
2574
|
restoreParentheses,
|
|
2520
2575
|
afterJoin,
|
|
2521
2576
|
finalizeWithNewLine,
|
|
2522
|
-
(
|
|
2577
|
+
({ storage, cfg: { general } }) => {
|
|
2523
2578
|
general.doEscapeCapitalized = storage.doEscapeCapitalized;
|
|
2524
|
-
return _;
|
|
2525
2579
|
}
|
|
2526
2580
|
];
|
|
2527
2581
|
var createPipeline = (resolveSpecialSyntax2, applyG, applyVariations, finalize2, highlightDiffStep2) => [
|
|
@@ -2546,17 +2600,17 @@ var createPipeline = (resolveSpecialSyntax2, applyG, applyVariations, finalize2,
|
|
|
2546
2600
|
applyNoFix,
|
|
2547
2601
|
finalize2
|
|
2548
2602
|
];
|
|
2549
|
-
var
|
|
2603
|
+
var plainText = createPipeline(
|
|
2550
2604
|
resolveSpecialSyntaxWithLAB,
|
|
2551
|
-
|
|
2552
|
-
|
|
2605
|
+
applyGNonHtml,
|
|
2606
|
+
applyVariationsNonHtml,
|
|
2553
2607
|
finalizeWithNewLine,
|
|
2554
|
-
|
|
2608
|
+
highlightDiffStepNonHtml
|
|
2555
2609
|
);
|
|
2556
|
-
var
|
|
2610
|
+
var html = createPipeline(
|
|
2557
2611
|
resolveSpecialSyntax("<"),
|
|
2558
|
-
|
|
2559
|
-
|
|
2612
|
+
applyGHtml,
|
|
2613
|
+
applyVariationsHtml,
|
|
2560
2614
|
finalize("<br>"),
|
|
2561
2615
|
highlightDiffStep(htmlWrappers.fix)
|
|
2562
2616
|
);
|
|
@@ -2565,11 +2619,9 @@ var htmlPipeline = createPipeline(
|
|
|
2565
2619
|
REPLACE_J,
|
|
2566
2620
|
TaraskConfig,
|
|
2567
2621
|
VARIATION,
|
|
2568
|
-
abcOnlyPipeline,
|
|
2569
2622
|
dicts,
|
|
2570
|
-
htmlPipeline,
|
|
2571
2623
|
lib,
|
|
2572
|
-
|
|
2624
|
+
pipelines,
|
|
2573
2625
|
steps,
|
|
2574
2626
|
tarask
|
|
2575
2627
|
});
|