taraskevizer 3.0.0 → 3.1.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 +12 -8
- package/dist/index.cjs +10 -15
- package/dist/index.js +10 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,10 +9,9 @@ $ npm i taraskevizer
|
|
|
9
9
|
```js
|
|
10
10
|
import { tarask, taraskToHtml, ALPHABET, J, VARIATION } from 'taraskevizer';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
// плянэта
|
|
12
|
+
tarask('планета'); // "плянэта"
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
tarask(
|
|
16
15
|
'планета і Гродна',
|
|
17
16
|
{
|
|
18
17
|
abc: ALPHABET.CYRILLIC,
|
|
@@ -23,10 +22,9 @@ const taraskedText = tarask(
|
|
|
23
22
|
variations: VARIATION.FIRST,
|
|
24
23
|
h: false,
|
|
25
24
|
}
|
|
26
|
-
);
|
|
27
|
-
// 'пл\x1b[32mя\x1b[0mн\x1b[32mэ\x1b[0mта \x1b[32mй\x1b[0m \x1b[35mГорадня\x1b[0m'
|
|
25
|
+
); // "пл\x1b[32mя\x1b[0mн\x1b[32mэ\x1b[0mта \x1b[32mй\x1b[0m \x1b[35mГорадня\x1b[0m"
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
taraskToHtml(
|
|
30
28
|
'энергія планеты',
|
|
31
29
|
{
|
|
32
30
|
abc: ALPHABET.LATIN,
|
|
@@ -34,8 +32,7 @@ const taraskedTextHtml = taraskToHtml(
|
|
|
34
32
|
{
|
|
35
33
|
g: false, // ignored, because alphabet is set to latin
|
|
36
34
|
}
|
|
37
|
-
);
|
|
38
|
-
// en<tarF>erg</tarF>ija p<tarF>lan</tarF>ety
|
|
35
|
+
); // "en<tarF>erg</tarF>ija p<tarF>lan</tarF>ety"
|
|
39
36
|
```
|
|
40
37
|
|
|
41
38
|
### Function signatures are in [this file](./dist/index.d.ts) (not available if project is not built)
|
|
@@ -178,6 +175,13 @@ Can be replaced by `ґ`(`g`) letter. appears only if alphabet is cyrillic
|
|
|
178
175
|
<tarH>Г</tarH>валт
|
|
179
176
|
```
|
|
180
177
|
|
|
178
|
+
## Special Constructions
|
|
179
|
+
|
|
180
|
+
| | fix | no fix |
|
|
181
|
+
| ----------- | ------------ | ------------ |
|
|
182
|
+
| brackets | `<,Планета>` | `<Планета>` |
|
|
183
|
+
| no brackets | `Планета` | `<.Планета>` |
|
|
184
|
+
|
|
181
185
|
# CLI
|
|
182
186
|
|
|
183
187
|
## Install
|
package/dist/index.cjs
CHANGED
|
@@ -2177,14 +2177,14 @@ var afterTarask = [
|
|
|
2177
2177
|
($0, $1, $2) => /([ая]ў|ну)$/.test($2) ? $1 + "ь і" + $2 : $0
|
|
2178
2178
|
]
|
|
2179
2179
|
];
|
|
2180
|
-
var noFix = [];
|
|
2181
2180
|
var process = (text, LEFT_ANGLE_BRACKET, options) => {
|
|
2182
2181
|
const { abc, j, OVERRIDE_toTarask: _toTarask = toTarask } = options;
|
|
2183
|
-
const
|
|
2184
|
-
text = ` ${text.trim()} `.replace(//g, "").replace(/<([,.]?)(
|
|
2182
|
+
const noFixArr = [];
|
|
2183
|
+
text = ` ${text.trim()} `.replace(//g, "").replace(/<([,.]?)(.*?)>/gs, ($0, $1, $2) => {
|
|
2184
|
+
console.log($0, ":", $1, ",", $2);
|
|
2185
2185
|
if ($1 === ",")
|
|
2186
2186
|
return LEFT_ANGLE_BRACKET + $2 + ">";
|
|
2187
|
-
|
|
2187
|
+
noFixArr.push($1 === "." ? $2 : $0);
|
|
2188
2188
|
return NOFIX_CHAR;
|
|
2189
2189
|
}).replace(/г'(?![еёіюя])/g, "ґ").replace(/([\n\t])/g, " $1 ").replace(/ - /g, " — ").replace(new RegExp("(\\p{P}|\\p{S}|\\d)", "gu"), " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "(");
|
|
2190
2190
|
let splittedOrig, splitted;
|
|
@@ -2207,14 +2207,9 @@ var process = (text, LEFT_ANGLE_BRACKET, options) => {
|
|
|
2207
2207
|
splitted = text.split(" ");
|
|
2208
2208
|
if (abc !== ALPHABET.ARABIC)
|
|
2209
2209
|
splitted = restoreCase(splitted, splittedOrig);
|
|
2210
|
-
return { splittedOrig, splitted };
|
|
2211
|
-
};
|
|
2212
|
-
var applyNoFix = (text) => {
|
|
2213
|
-
if (noFix.length)
|
|
2214
|
-
text = text.replace(NOFIX_REGEX, () => noFix.shift());
|
|
2215
|
-
noFix = [];
|
|
2216
|
-
return text;
|
|
2210
|
+
return { splittedOrig, splitted, noFixArr };
|
|
2217
2211
|
};
|
|
2212
|
+
var applyNoFix = (arr2, text) => arr2.length ? text.replace(NOFIX_REGEX, () => arr2.shift()) : text;
|
|
2218
2213
|
var join = (textArr) => textArr.join(" ").replace(/ /g, " ").replace(new RegExp(" (\\p{P}|\\p{S}|\\d|() ", "gu"), "$1");
|
|
2219
2214
|
var finilize = (text, newLine) => text.replace(/ \t /g, " ").replace(/ \n /g, newLine).trim();
|
|
2220
2215
|
var replaceG = (text, replacer) => text.replace(
|
|
@@ -2231,7 +2226,7 @@ var taraskToHtml = (text, taraskOptions, htmlOptions = {}) => {
|
|
|
2231
2226
|
const options = getCompletedOptions(taraskOptions);
|
|
2232
2227
|
const wrapInTag = wrappers.html;
|
|
2233
2228
|
const isCyrillic = options.abc === ALPHABET.CYRILLIC;
|
|
2234
|
-
const { splitted, splittedOrig } = process(text, "<", options);
|
|
2229
|
+
const { splitted, splittedOrig, noFixArr } = process(text, "<", options);
|
|
2235
2230
|
highlightChanges(splitted, splittedOrig, isCyrillic, wrapInTag.fix);
|
|
2236
2231
|
text = join(splitted);
|
|
2237
2232
|
if (isCyrillic)
|
|
@@ -2240,7 +2235,7 @@ var taraskToHtml = (text, taraskOptions, htmlOptions = {}) => {
|
|
|
2240
2235
|
htmlOptions.g ? wrapInTag.letterH("$&") : ($0) => wrapInTag.letterH(gobj[$0])
|
|
2241
2236
|
);
|
|
2242
2237
|
return finilize(
|
|
2243
|
-
applyNoFix(text).replace(OPTIONAL_WORDS_REGEX, ($0) => {
|
|
2238
|
+
applyNoFix(noFixArr, text).replace(OPTIONAL_WORDS_REGEX, ($0) => {
|
|
2244
2239
|
const options2 = $0.slice(1, -1).split("|");
|
|
2245
2240
|
const main = options2.shift();
|
|
2246
2241
|
return `<tarL data-l='${options2}'>${main}</tarL>`;
|
|
@@ -2252,7 +2247,7 @@ var tarask = (text, taraskOptions, nonHtmlOptions = {}) => {
|
|
|
2252
2247
|
const options = getCompletedOptions(taraskOptions);
|
|
2253
2248
|
const wrapInColorOf = wrappers.ansiColors;
|
|
2254
2249
|
const isCyrillic = options.abc === ALPHABET.CYRILLIC;
|
|
2255
|
-
const { splitted, splittedOrig } = process(text, "
|
|
2250
|
+
const { splitted, splittedOrig, noFixArr } = process(text, "<", options);
|
|
2256
2251
|
if (nonHtmlOptions.ansiColors)
|
|
2257
2252
|
highlightChanges(splitted, splittedOrig, isCyrillic, wrapInColorOf.fix);
|
|
2258
2253
|
text = join(splitted);
|
|
@@ -2269,7 +2264,7 @@ var tarask = (text, taraskOptions, nonHtmlOptions = {}) => {
|
|
|
2269
2264
|
nonHtmlOptions.ansiColors ? ($0) => wrapInColorOf.variable(replacer($0)) : replacer
|
|
2270
2265
|
);
|
|
2271
2266
|
}
|
|
2272
|
-
return finilize(applyNoFix(text).replace(/(/g, "("), "\n");
|
|
2267
|
+
return finilize(applyNoFix(noFixArr, text).replace(/(/g, "("), "\n");
|
|
2273
2268
|
};
|
|
2274
2269
|
var restoreCase = (text, orig) => {
|
|
2275
2270
|
for (let i = 0; i < text.length; i++) {
|
package/dist/index.js
CHANGED
|
@@ -2146,14 +2146,14 @@ var afterTarask = [
|
|
|
2146
2146
|
($0, $1, $2) => /([ая]ў|ну)$/.test($2) ? $1 + "ь і" + $2 : $0
|
|
2147
2147
|
]
|
|
2148
2148
|
];
|
|
2149
|
-
var noFix = [];
|
|
2150
2149
|
var process = (text, LEFT_ANGLE_BRACKET, options) => {
|
|
2151
2150
|
const { abc, j, OVERRIDE_toTarask: _toTarask = toTarask } = options;
|
|
2152
|
-
const
|
|
2153
|
-
text = ` ${text.trim()} `.replace(//g, "").replace(/<([,.]?)(
|
|
2151
|
+
const noFixArr = [];
|
|
2152
|
+
text = ` ${text.trim()} `.replace(//g, "").replace(/<([,.]?)(.*?)>/gs, ($0, $1, $2) => {
|
|
2153
|
+
console.log($0, ":", $1, ",", $2);
|
|
2154
2154
|
if ($1 === ",")
|
|
2155
2155
|
return LEFT_ANGLE_BRACKET + $2 + ">";
|
|
2156
|
-
|
|
2156
|
+
noFixArr.push($1 === "." ? $2 : $0);
|
|
2157
2157
|
return NOFIX_CHAR;
|
|
2158
2158
|
}).replace(/г'(?![еёіюя])/g, "ґ").replace(/([\n\t])/g, " $1 ").replace(/ - /g, " — ").replace(new RegExp("(\\p{P}|\\p{S}|\\d)", "gu"), " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "(");
|
|
2159
2159
|
let splittedOrig, splitted;
|
|
@@ -2176,14 +2176,9 @@ var process = (text, LEFT_ANGLE_BRACKET, options) => {
|
|
|
2176
2176
|
splitted = text.split(" ");
|
|
2177
2177
|
if (abc !== ALPHABET.ARABIC)
|
|
2178
2178
|
splitted = restoreCase(splitted, splittedOrig);
|
|
2179
|
-
return { splittedOrig, splitted };
|
|
2180
|
-
};
|
|
2181
|
-
var applyNoFix = (text) => {
|
|
2182
|
-
if (noFix.length)
|
|
2183
|
-
text = text.replace(NOFIX_REGEX, () => noFix.shift());
|
|
2184
|
-
noFix = [];
|
|
2185
|
-
return text;
|
|
2179
|
+
return { splittedOrig, splitted, noFixArr };
|
|
2186
2180
|
};
|
|
2181
|
+
var applyNoFix = (arr2, text) => arr2.length ? text.replace(NOFIX_REGEX, () => arr2.shift()) : text;
|
|
2187
2182
|
var join = (textArr) => textArr.join(" ").replace(/ /g, " ").replace(new RegExp(" (\\p{P}|\\p{S}|\\d|() ", "gu"), "$1");
|
|
2188
2183
|
var finilize = (text, newLine) => text.replace(/ \t /g, " ").replace(/ \n /g, newLine).trim();
|
|
2189
2184
|
var replaceG = (text, replacer) => text.replace(
|
|
@@ -2200,7 +2195,7 @@ var taraskToHtml = (text, taraskOptions, htmlOptions = {}) => {
|
|
|
2200
2195
|
const options = getCompletedOptions(taraskOptions);
|
|
2201
2196
|
const wrapInTag = wrappers.html;
|
|
2202
2197
|
const isCyrillic = options.abc === ALPHABET.CYRILLIC;
|
|
2203
|
-
const { splitted, splittedOrig } = process(text, "<", options);
|
|
2198
|
+
const { splitted, splittedOrig, noFixArr } = process(text, "<", options);
|
|
2204
2199
|
highlightChanges(splitted, splittedOrig, isCyrillic, wrapInTag.fix);
|
|
2205
2200
|
text = join(splitted);
|
|
2206
2201
|
if (isCyrillic)
|
|
@@ -2209,7 +2204,7 @@ var taraskToHtml = (text, taraskOptions, htmlOptions = {}) => {
|
|
|
2209
2204
|
htmlOptions.g ? wrapInTag.letterH("$&") : ($0) => wrapInTag.letterH(gobj[$0])
|
|
2210
2205
|
);
|
|
2211
2206
|
return finilize(
|
|
2212
|
-
applyNoFix(text).replace(OPTIONAL_WORDS_REGEX, ($0) => {
|
|
2207
|
+
applyNoFix(noFixArr, text).replace(OPTIONAL_WORDS_REGEX, ($0) => {
|
|
2213
2208
|
const options2 = $0.slice(1, -1).split("|");
|
|
2214
2209
|
const main = options2.shift();
|
|
2215
2210
|
return `<tarL data-l='${options2}'>${main}</tarL>`;
|
|
@@ -2221,7 +2216,7 @@ var tarask = (text, taraskOptions, nonHtmlOptions = {}) => {
|
|
|
2221
2216
|
const options = getCompletedOptions(taraskOptions);
|
|
2222
2217
|
const wrapInColorOf = wrappers.ansiColors;
|
|
2223
2218
|
const isCyrillic = options.abc === ALPHABET.CYRILLIC;
|
|
2224
|
-
const { splitted, splittedOrig } = process(text, "
|
|
2219
|
+
const { splitted, splittedOrig, noFixArr } = process(text, "<", options);
|
|
2225
2220
|
if (nonHtmlOptions.ansiColors)
|
|
2226
2221
|
highlightChanges(splitted, splittedOrig, isCyrillic, wrapInColorOf.fix);
|
|
2227
2222
|
text = join(splitted);
|
|
@@ -2238,7 +2233,7 @@ var tarask = (text, taraskOptions, nonHtmlOptions = {}) => {
|
|
|
2238
2233
|
nonHtmlOptions.ansiColors ? ($0) => wrapInColorOf.variable(replacer($0)) : replacer
|
|
2239
2234
|
);
|
|
2240
2235
|
}
|
|
2241
|
-
return finilize(applyNoFix(text).replace(/(/g, "("), "\n");
|
|
2236
|
+
return finilize(applyNoFix(noFixArr, text).replace(/(/g, "("), "\n");
|
|
2242
2237
|
};
|
|
2243
2238
|
var restoreCase = (text, orig) => {
|
|
2244
2239
|
for (let i = 0; i < text.length; i++) {
|