taraskevizer 1.0.2 → 1.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 +5 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -5
- package/dist/index.mjs +8 -5
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -39,6 +39,7 @@ Type: `number`
|
|
|
39
39
|
Default value: `0`
|
|
40
40
|
|
|
41
41
|
Alphabet of output text:
|
|
42
|
+
|
|
42
43
|
```
|
|
43
44
|
0 = cyrillic
|
|
44
45
|
1 = latin
|
|
@@ -52,6 +53,7 @@ Type: `number`
|
|
|
52
53
|
Default value: `0`
|
|
53
54
|
|
|
54
55
|
When to replace `і`(`i`) by `й`(`j`) after vowels:
|
|
56
|
+
|
|
55
57
|
```
|
|
56
58
|
0 = never
|
|
57
59
|
1 = random
|
|
@@ -75,7 +77,9 @@ Default value: `false`
|
|
|
75
77
|
Do replace `г`(`h`) by `ґ`(`g`) in cyrillic alphabet?
|
|
76
78
|
|
|
77
79
|
```html
|
|
78
|
-
false: <tarH>г</tarH> <tarH>Г</tarH>
|
|
80
|
+
false: <tarH>г</tarH> <tarH>Г</tarH>
|
|
81
|
+
|
|
82
|
+
true: <tarH>ґ</tarH> <tarH>Ґ</tarH>
|
|
79
83
|
```
|
|
80
84
|
|
|
81
85
|
## HTML tags
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ type TaraskOptions = {
|
|
|
9
9
|
html: false | HtmlOptions;
|
|
10
10
|
};
|
|
11
11
|
type Promisify<T> = T extends (...args: infer TArgs) => infer TReturn ? (...args: TArgs) => Promise<TReturn> : never;
|
|
12
|
-
type Tarask = (text: string, options
|
|
12
|
+
type Tarask = (text: string, options?: TaraskOptions) => string;
|
|
13
13
|
type TaraskAsync = Promisify<Tarask>;
|
|
14
14
|
type Dict = Record<string, RegExp>;
|
|
15
15
|
type AlphabetDependentDict = {
|
package/dist/index.js
CHANGED
|
@@ -1996,7 +1996,8 @@ var additionalReplacements = {
|
|
|
1996
1996
|
},
|
|
1997
1997
|
[ARABIC]: {}
|
|
1998
1998
|
};
|
|
1999
|
-
var taraskSync = (text,
|
|
1999
|
+
var taraskSync = (text, options) => {
|
|
2000
|
+
const { abc = 0, j = 0, html = false } = options || {};
|
|
2000
2001
|
const noFix = [];
|
|
2001
2002
|
const LEFT_ANGLE_BRACKET = html ? "<" : "<";
|
|
2002
2003
|
text = ` ${text.trim()} `.replace(/<([,.]?)((?:.|\s)*?)>/g, ($0, $1, $2) => {
|
|
@@ -2004,7 +2005,7 @@ var taraskSync = (text, { abc = 0, j = 0, html }) => {
|
|
|
2004
2005
|
return LEFT_ANGLE_BRACKET + $2 + ">";
|
|
2005
2006
|
noFix[noFix.length] = $1 === "." ? $2 : $0;
|
|
2006
2007
|
return NOFIX_CHAR;
|
|
2007
|
-
}).replace(/г'(?![еёіюя])/g, "ґ").replace(/(\n
|
|
2008
|
+
}).replace(/г'(?![еёіюя])/g, "ґ").replace(/([\n\t])/g, " $1 ").replace(/ - /g, " — ").replace(/(\p{P}|\p{S}|\d)/gu, " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "(");
|
|
2008
2009
|
let splittedOrig, splitted;
|
|
2009
2010
|
splittedOrig = replaceWithDict(
|
|
2010
2011
|
replaceWithDict(text, letters[abc]),
|
|
@@ -2096,8 +2097,10 @@ function toHtmlTags(text, orig, abc) {
|
|
|
2096
2097
|
let fromOWordEnd = oWordEnd;
|
|
2097
2098
|
while (wordH[fromStart] === oWord[fromStart])
|
|
2098
2099
|
++fromStart;
|
|
2099
|
-
while (wordH[fromWordEnd] === oWord[fromOWordEnd])
|
|
2100
|
-
--fromWordEnd
|
|
2100
|
+
while (wordH[fromWordEnd] === oWord[fromOWordEnd]) {
|
|
2101
|
+
--fromWordEnd;
|
|
2102
|
+
--fromOWordEnd;
|
|
2103
|
+
}
|
|
2101
2104
|
if (oWord.length < word.length) {
|
|
2102
2105
|
if (fromOWordEnd === oWordEnd) {
|
|
2103
2106
|
text[i] = `<tarF>${word}</tarF>`;
|
|
@@ -2129,7 +2132,7 @@ function toTarask(text) {
|
|
|
2129
2132
|
($0, $1, $2) => /([ая]ў|ну)$/.test($2) ? $1 + "ь і" + $2 : $0
|
|
2130
2133
|
);
|
|
2131
2134
|
}
|
|
2132
|
-
function replaceWithDict(text, dict =
|
|
2135
|
+
function replaceWithDict(text, dict = {}) {
|
|
2133
2136
|
for (const key in dict)
|
|
2134
2137
|
text = text.replace(dict[key], key);
|
|
2135
2138
|
return text;
|
package/dist/index.mjs
CHANGED
|
@@ -1969,7 +1969,8 @@ var additionalReplacements = {
|
|
|
1969
1969
|
},
|
|
1970
1970
|
[ARABIC]: {}
|
|
1971
1971
|
};
|
|
1972
|
-
var taraskSync = (text,
|
|
1972
|
+
var taraskSync = (text, options) => {
|
|
1973
|
+
const { abc = 0, j = 0, html = false } = options || {};
|
|
1973
1974
|
const noFix = [];
|
|
1974
1975
|
const LEFT_ANGLE_BRACKET = html ? "<" : "<";
|
|
1975
1976
|
text = ` ${text.trim()} `.replace(/<([,.]?)((?:.|\s)*?)>/g, ($0, $1, $2) => {
|
|
@@ -1977,7 +1978,7 @@ var taraskSync = (text, { abc = 0, j = 0, html }) => {
|
|
|
1977
1978
|
return LEFT_ANGLE_BRACKET + $2 + ">";
|
|
1978
1979
|
noFix[noFix.length] = $1 === "." ? $2 : $0;
|
|
1979
1980
|
return NOFIX_CHAR;
|
|
1980
|
-
}).replace(/г'(?![еёіюя])/g, "ґ").replace(/(\n
|
|
1981
|
+
}).replace(/г'(?![еёіюя])/g, "ґ").replace(/([\n\t])/g, " $1 ").replace(/ - /g, " — ").replace(/(\p{P}|\p{S}|\d)/gu, " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "(");
|
|
1981
1982
|
let splittedOrig, splitted;
|
|
1982
1983
|
splittedOrig = replaceWithDict(
|
|
1983
1984
|
replaceWithDict(text, letters[abc]),
|
|
@@ -2069,8 +2070,10 @@ function toHtmlTags(text, orig, abc) {
|
|
|
2069
2070
|
let fromOWordEnd = oWordEnd;
|
|
2070
2071
|
while (wordH[fromStart] === oWord[fromStart])
|
|
2071
2072
|
++fromStart;
|
|
2072
|
-
while (wordH[fromWordEnd] === oWord[fromOWordEnd])
|
|
2073
|
-
--fromWordEnd
|
|
2073
|
+
while (wordH[fromWordEnd] === oWord[fromOWordEnd]) {
|
|
2074
|
+
--fromWordEnd;
|
|
2075
|
+
--fromOWordEnd;
|
|
2076
|
+
}
|
|
2074
2077
|
if (oWord.length < word.length) {
|
|
2075
2078
|
if (fromOWordEnd === oWordEnd) {
|
|
2076
2079
|
text[i] = `<tarF>${word}</tarF>`;
|
|
@@ -2102,7 +2105,7 @@ function toTarask(text) {
|
|
|
2102
2105
|
($0, $1, $2) => /([ая]ў|ну)$/.test($2) ? $1 + "ь і" + $2 : $0
|
|
2103
2106
|
);
|
|
2104
2107
|
}
|
|
2105
|
-
function replaceWithDict(text, dict =
|
|
2108
|
+
function replaceWithDict(text, dict = {}) {
|
|
2106
2109
|
for (const key in dict)
|
|
2107
2110
|
text = text.replace(dict[key], key);
|
|
2108
2111
|
return text;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "taraskevizer",
|
|
3
3
|
"author": "GooseOb",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.0
|
|
5
|
+
"version": "1.1.0",
|
|
6
6
|
"private": false,
|
|
7
7
|
"homepage": "https://gooseob.github.io/taraskevizatar/",
|
|
8
8
|
"main": "dist/index.js",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "tsup --config build-config/index.js",
|
|
17
|
+
"test": "node test",
|
|
17
18
|
"prepare": "husky install"
|
|
18
19
|
},
|
|
19
20
|
"repository": {
|
|
@@ -28,6 +29,7 @@
|
|
|
28
29
|
"belarusian"
|
|
29
30
|
],
|
|
30
31
|
"devDependencies": {
|
|
32
|
+
"@digitak/esrun": "^3.2.24",
|
|
31
33
|
"husky": "^8.0.3",
|
|
32
34
|
"prettier": "^3.0.0",
|
|
33
35
|
"tsup": "^6.5.0",
|