taraskevizer 1.2.2 → 1.3.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/dist/index.cjs +31 -25
- package/dist/index.d.ts +48 -33
- package/dist/index.js +28 -25
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -19,6 +19,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/index.ts
|
|
20
20
|
var src_exports = {};
|
|
21
21
|
__export(src_exports, {
|
|
22
|
+
ALPHABET: () => ALPHABET,
|
|
23
|
+
J: () => J,
|
|
24
|
+
VARIATION: () => VARIATION,
|
|
22
25
|
gobj: () => gobj,
|
|
23
26
|
tarask: () => tarask,
|
|
24
27
|
taraskSync: () => taraskSync
|
|
@@ -842,9 +845,10 @@ var rawWordlist = [
|
|
|
842
845
|
["сэйшэл", /сейшэл/],
|
|
843
846
|
["сэкстын", /сексцін/],
|
|
844
847
|
// Сэкстына, места
|
|
845
|
-
["сэк", /сек(?=[ст])/],
|
|
848
|
+
["сэк", /сек(?=[ст]|цы)/],
|
|
846
849
|
// сэкстант
|
|
847
850
|
["сэкунд", /секунд/],
|
|
851
|
+
[" сэлек", / селек(?=[тц])/],
|
|
848
852
|
["сэмант", /семант/],
|
|
849
853
|
["сэмі", /семі(?=т|ц|нар)/],
|
|
850
854
|
["сэмэстр", /семестр/],
|
|
@@ -1973,27 +1977,26 @@ var NOFIX_CHAR = "
|
|
|
1973
1977
|
var NOFIX_REGEX = new RegExp(NOFIX_CHAR, "g");
|
|
1974
1978
|
var OPTIONAL_WORDS_REGEX = /\(.*?\)/g;
|
|
1975
1979
|
var G_REGEX = /[Ґґ]/g;
|
|
1976
|
-
var
|
|
1977
|
-
var
|
|
1978
|
-
var
|
|
1979
|
-
var J_ALWAYS = 2;
|
|
1980
|
+
var ALPHABET = { CYRILLIC: 0, LATIN: 1, ARABIC: 2 };
|
|
1981
|
+
var J = { NEVER: 0, RANDOM: 1, ALWAYS: 2 };
|
|
1982
|
+
var VARIATION = { NO: 0, FIRST: 1, ALL: 2 };
|
|
1980
1983
|
var letters = {
|
|
1981
|
-
[LATIN]: latinLetters,
|
|
1982
|
-
[ARABIC]: arabLetters
|
|
1984
|
+
[ALPHABET.LATIN]: latinLetters,
|
|
1985
|
+
[ALPHABET.ARABIC]: arabLetters
|
|
1983
1986
|
};
|
|
1984
1987
|
var lettersUpperCase = {
|
|
1985
|
-
[LATIN]: latinLettersUpperCase
|
|
1988
|
+
[ALPHABET.LATIN]: latinLettersUpperCase
|
|
1986
1989
|
};
|
|
1987
1990
|
var additionalReplacements = {
|
|
1988
|
-
[CYRILLIC]: [
|
|
1991
|
+
[ALPHABET.CYRILLIC]: [
|
|
1989
1992
|
["$1У", /([АЕЁІОУЫЭЮЯ])<tarF>Ў<\/tarF>/g],
|
|
1990
1993
|
[" У", / <tarF>Ў<\/tarF>(?=\p{Lu})/gu]
|
|
1991
1994
|
],
|
|
1992
|
-
[LATIN]: [
|
|
1995
|
+
[ALPHABET.LATIN]: [
|
|
1993
1996
|
["$1U", /([AEIOUY])<tarF>Ŭ<\/tarF>/g],
|
|
1994
1997
|
[" U", / <tarF>Ŭ<\/tarF>(?=\p{Lu})/gu]
|
|
1995
1998
|
],
|
|
1996
|
-
[ARABIC]: []
|
|
1999
|
+
[ALPHABET.ARABIC]: []
|
|
1997
2000
|
};
|
|
1998
2001
|
var tagApplications = {
|
|
1999
2002
|
html: {
|
|
@@ -2027,10 +2030,10 @@ var taraskSync = (text, options) => {
|
|
|
2027
2030
|
).split(" ");
|
|
2028
2031
|
text = toTarask(text.toLowerCase());
|
|
2029
2032
|
if (j)
|
|
2030
|
-
text = replaceIbyJ(text, j ===
|
|
2033
|
+
text = replaceIbyJ(text, j === J.ALWAYS);
|
|
2031
2034
|
text = replaceWithDict(text, letters[abc]);
|
|
2032
2035
|
splitted = text.split(" ");
|
|
2033
|
-
if (abc !== ARABIC)
|
|
2036
|
+
if (abc !== ALPHABET.ARABIC)
|
|
2034
2037
|
splitted = restoreCase(splitted, splittedOrig);
|
|
2035
2038
|
const nodeColors = nonHtml && nonHtml.nodeColors;
|
|
2036
2039
|
if (html || nodeColors)
|
|
@@ -2039,10 +2042,10 @@ var taraskSync = (text, options) => {
|
|
|
2039
2042
|
let gReplacer;
|
|
2040
2043
|
if (html) {
|
|
2041
2044
|
text = replaceWithDict(text, additionalReplacements[abc]);
|
|
2042
|
-
if (abc === CYRILLIC) {
|
|
2045
|
+
if (abc === ALPHABET.CYRILLIC) {
|
|
2043
2046
|
gReplacer = html.g ? apply.H("$&") : ($0) => apply.H(gobj[$0]);
|
|
2044
2047
|
}
|
|
2045
|
-
} else if (nonHtml && abc === CYRILLIC) {
|
|
2048
|
+
} else if (nonHtml && abc === ALPHABET.CYRILLIC) {
|
|
2046
2049
|
if (nonHtml.nodeColors) {
|
|
2047
2050
|
gReplacer = nonHtml.h ? ($0) => apply.H(gobj[$0]) : apply.H("$&");
|
|
2048
2051
|
} else if (nonHtml.h) {
|
|
@@ -2053,7 +2056,7 @@ var taraskSync = (text, options) => {
|
|
|
2053
2056
|
text = text.replace(G_REGEX, gReplacer);
|
|
2054
2057
|
if (noFix.length)
|
|
2055
2058
|
text = text.replace(NOFIX_REGEX, () => noFix.shift());
|
|
2056
|
-
return (html ? finalizer.html(text) : finalizer.nonHtml(text, nonHtml
|
|
2059
|
+
return (html ? finalizer.html(text) : finalizer.nonHtml(text, nonHtml)).trim();
|
|
2057
2060
|
};
|
|
2058
2061
|
var tarask = (...args) => new Promise((res) => res(taraskSync(...args)));
|
|
2059
2062
|
function restoreCase(text, orig) {
|
|
@@ -2092,15 +2095,15 @@ function toTags(text, orig, abc, applyF) {
|
|
|
2092
2095
|
continue;
|
|
2093
2096
|
if (!/\(/.test(word)) {
|
|
2094
2097
|
if (word.length === oWord.length) {
|
|
2095
|
-
const
|
|
2096
|
-
for (let
|
|
2097
|
-
if (
|
|
2098
|
-
|
|
2098
|
+
const wordLetters = word.split("");
|
|
2099
|
+
for (let j = 0; j < wordLetters.length; j++) {
|
|
2100
|
+
if (wordH[j] !== oWord[j])
|
|
2101
|
+
wordLetters[j] = applyF(wordLetters[j]);
|
|
2099
2102
|
}
|
|
2100
|
-
text[i] =
|
|
2103
|
+
text[i] = wordLetters.join("");
|
|
2101
2104
|
continue;
|
|
2102
2105
|
}
|
|
2103
|
-
if (abc === CYRILLIC) {
|
|
2106
|
+
if (abc === ALPHABET.CYRILLIC) {
|
|
2104
2107
|
const word1 = word.replace(/ь/g, "");
|
|
2105
2108
|
switch (oWord) {
|
|
2106
2109
|
case word1:
|
|
@@ -2171,13 +2174,13 @@ var finalizer = {
|
|
|
2171
2174
|
const main = options.shift();
|
|
2172
2175
|
return `<tarL data-l='${options}'>${main}</tarL>`;
|
|
2173
2176
|
}).replace(/ \n /g, "<br>"),
|
|
2174
|
-
nonHtml(text, options
|
|
2175
|
-
if (options && options.variations !==
|
|
2177
|
+
nonHtml(text, options) {
|
|
2178
|
+
if (options && options.variations !== VARIATION.ALL) {
|
|
2176
2179
|
const WORD_INDEX = options.variations;
|
|
2177
2180
|
const replacer = ($0) => $0.slice(1, -1).split("|")[WORD_INDEX];
|
|
2178
2181
|
text = text.replace(
|
|
2179
2182
|
OPTIONAL_WORDS_REGEX,
|
|
2180
|
-
options.nodeColors ? ($0) =>
|
|
2183
|
+
options.nodeColors ? ($0) => tagApplications.nonHtml.L(replacer($0)) : replacer
|
|
2181
2184
|
);
|
|
2182
2185
|
}
|
|
2183
2186
|
return text.replace(/(/g, "(");
|
|
@@ -2185,6 +2188,9 @@ var finalizer = {
|
|
|
2185
2188
|
};
|
|
2186
2189
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2187
2190
|
0 && (module.exports = {
|
|
2191
|
+
ALPHABET,
|
|
2192
|
+
J,
|
|
2193
|
+
VARIATION,
|
|
2188
2194
|
gobj,
|
|
2189
2195
|
tarask,
|
|
2190
2196
|
taraskSync
|
package/dist/index.d.ts
CHANGED
|
@@ -1,39 +1,54 @@
|
|
|
1
|
-
type Promisify<T> = T extends (...args: infer TArgs) => infer TReturn ? (...args: TArgs) => Promise<TReturn> : never;
|
|
2
|
-
type DeepPartial<T> = T extends object ? {
|
|
3
|
-
[P in keyof T]?: DeepPartial<T[P]>;
|
|
4
|
-
} : T;
|
|
5
|
-
type Alphabet = 0 | 1 | 2;
|
|
6
|
-
type J = 0 | 1 | 2;
|
|
7
|
-
type Variation = 0 | 1 | 2;
|
|
8
|
-
type NonHtmlOptions = {
|
|
9
|
-
nodeColors: boolean;
|
|
10
|
-
h: boolean;
|
|
11
|
-
variations: Variation;
|
|
12
|
-
};
|
|
13
|
-
type HtmlOptions = {
|
|
14
|
-
g: boolean;
|
|
15
|
-
};
|
|
16
|
-
type TaraskOptions = DeepPartial<{
|
|
17
|
-
abc: Alphabet;
|
|
18
|
-
j: J;
|
|
19
|
-
html: false | HtmlOptions;
|
|
20
|
-
nonHtml: false | NonHtmlOptions;
|
|
21
|
-
}>;
|
|
22
|
-
type Tarask = (text: string, options?: TaraskOptions) => string;
|
|
23
|
-
type TaraskAsync = Promisify<Tarask>;
|
|
24
|
-
type Dict<T = RegExp> = [string, T][];
|
|
25
|
-
type AlphabetDependentDict = {
|
|
26
|
-
[key in Alphabet]?: Dict;
|
|
1
|
+
type Promisify<T> = T extends (...args: infer TArgs) => infer TReturn ? (...args: TArgs) => Promise<TReturn> : never;
|
|
2
|
+
type DeepPartial<T> = T extends object ? {
|
|
3
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
4
|
+
} : T;
|
|
5
|
+
type Alphabet = 0 | 1 | 2;
|
|
6
|
+
type J$1 = 0 | 1 | 2;
|
|
7
|
+
type Variation = 0 | 1 | 2;
|
|
8
|
+
type NonHtmlOptions = {
|
|
9
|
+
nodeColors: boolean;
|
|
10
|
+
h: boolean;
|
|
11
|
+
variations: Variation;
|
|
12
|
+
};
|
|
13
|
+
type HtmlOptions = {
|
|
14
|
+
g: boolean;
|
|
15
|
+
};
|
|
16
|
+
type TaraskOptions = DeepPartial<{
|
|
17
|
+
abc: Alphabet;
|
|
18
|
+
j: J$1;
|
|
19
|
+
html: false | HtmlOptions;
|
|
20
|
+
nonHtml: false | NonHtmlOptions;
|
|
21
|
+
}>;
|
|
22
|
+
type Tarask = (text: string, options?: TaraskOptions) => string;
|
|
23
|
+
type TaraskAsync = Promisify<Tarask>;
|
|
24
|
+
type Dict<T = RegExp> = [string, T][];
|
|
25
|
+
type AlphabetDependentDict = {
|
|
26
|
+
[key in Alphabet]?: Dict;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
declare const
|
|
29
|
+
declare const ALPHABET: {
|
|
30
|
+
CYRILLIC: number;
|
|
31
|
+
LATIN: number;
|
|
32
|
+
ARABIC: number;
|
|
33
|
+
};
|
|
34
|
+
declare const J: {
|
|
35
|
+
NEVER: number;
|
|
36
|
+
RANDOM: number;
|
|
37
|
+
ALWAYS: number;
|
|
38
|
+
};
|
|
39
|
+
declare const VARIATION: {
|
|
40
|
+
NO: number;
|
|
41
|
+
FIRST: number;
|
|
42
|
+
ALL: number;
|
|
43
|
+
};
|
|
44
|
+
declare const taraskSync: Tarask;
|
|
30
45
|
declare const tarask: TaraskAsync;
|
|
31
46
|
|
|
32
|
-
declare const gobj: {
|
|
33
|
-
readonly г: "ґ";
|
|
34
|
-
readonly Г: "Ґ";
|
|
35
|
-
readonly ґ: "г";
|
|
36
|
-
readonly Ґ: "Г";
|
|
47
|
+
declare const gobj: {
|
|
48
|
+
readonly г: "ґ";
|
|
49
|
+
readonly Г: "Ґ";
|
|
50
|
+
readonly ґ: "г";
|
|
51
|
+
readonly Ґ: "Г";
|
|
37
52
|
};
|
|
38
53
|
|
|
39
|
-
export { AlphabetDependentDict, Dict, HtmlOptions, NonHtmlOptions, Tarask, TaraskAsync, TaraskOptions, gobj, tarask, taraskSync };
|
|
54
|
+
export { ALPHABET, AlphabetDependentDict, Dict, HtmlOptions, J, NonHtmlOptions, Tarask, TaraskAsync, TaraskOptions, VARIATION, gobj, tarask, taraskSync };
|
package/dist/index.js
CHANGED
|
@@ -815,9 +815,10 @@ var rawWordlist = [
|
|
|
815
815
|
["сэйшэл", /сейшэл/],
|
|
816
816
|
["сэкстын", /сексцін/],
|
|
817
817
|
// Сэкстына, места
|
|
818
|
-
["сэк", /сек(?=[ст])/],
|
|
818
|
+
["сэк", /сек(?=[ст]|цы)/],
|
|
819
819
|
// сэкстант
|
|
820
820
|
["сэкунд", /секунд/],
|
|
821
|
+
[" сэлек", / селек(?=[тц])/],
|
|
821
822
|
["сэмант", /семант/],
|
|
822
823
|
["сэмі", /семі(?=т|ц|нар)/],
|
|
823
824
|
["сэмэстр", /семестр/],
|
|
@@ -1946,27 +1947,26 @@ var NOFIX_CHAR = "
|
|
|
1946
1947
|
var NOFIX_REGEX = new RegExp(NOFIX_CHAR, "g");
|
|
1947
1948
|
var OPTIONAL_WORDS_REGEX = /\(.*?\)/g;
|
|
1948
1949
|
var G_REGEX = /[Ґґ]/g;
|
|
1949
|
-
var
|
|
1950
|
-
var
|
|
1951
|
-
var
|
|
1952
|
-
var J_ALWAYS = 2;
|
|
1950
|
+
var ALPHABET = { CYRILLIC: 0, LATIN: 1, ARABIC: 2 };
|
|
1951
|
+
var J = { NEVER: 0, RANDOM: 1, ALWAYS: 2 };
|
|
1952
|
+
var VARIATION = { NO: 0, FIRST: 1, ALL: 2 };
|
|
1953
1953
|
var letters = {
|
|
1954
|
-
[LATIN]: latinLetters,
|
|
1955
|
-
[ARABIC]: arabLetters
|
|
1954
|
+
[ALPHABET.LATIN]: latinLetters,
|
|
1955
|
+
[ALPHABET.ARABIC]: arabLetters
|
|
1956
1956
|
};
|
|
1957
1957
|
var lettersUpperCase = {
|
|
1958
|
-
[LATIN]: latinLettersUpperCase
|
|
1958
|
+
[ALPHABET.LATIN]: latinLettersUpperCase
|
|
1959
1959
|
};
|
|
1960
1960
|
var additionalReplacements = {
|
|
1961
|
-
[CYRILLIC]: [
|
|
1961
|
+
[ALPHABET.CYRILLIC]: [
|
|
1962
1962
|
["$1У", /([АЕЁІОУЫЭЮЯ])<tarF>Ў<\/tarF>/g],
|
|
1963
1963
|
[" У", / <tarF>Ў<\/tarF>(?=\p{Lu})/gu]
|
|
1964
1964
|
],
|
|
1965
|
-
[LATIN]: [
|
|
1965
|
+
[ALPHABET.LATIN]: [
|
|
1966
1966
|
["$1U", /([AEIOUY])<tarF>Ŭ<\/tarF>/g],
|
|
1967
1967
|
[" U", / <tarF>Ŭ<\/tarF>(?=\p{Lu})/gu]
|
|
1968
1968
|
],
|
|
1969
|
-
[ARABIC]: []
|
|
1969
|
+
[ALPHABET.ARABIC]: []
|
|
1970
1970
|
};
|
|
1971
1971
|
var tagApplications = {
|
|
1972
1972
|
html: {
|
|
@@ -2000,10 +2000,10 @@ var taraskSync = (text, options) => {
|
|
|
2000
2000
|
).split(" ");
|
|
2001
2001
|
text = toTarask(text.toLowerCase());
|
|
2002
2002
|
if (j)
|
|
2003
|
-
text = replaceIbyJ(text, j ===
|
|
2003
|
+
text = replaceIbyJ(text, j === J.ALWAYS);
|
|
2004
2004
|
text = replaceWithDict(text, letters[abc]);
|
|
2005
2005
|
splitted = text.split(" ");
|
|
2006
|
-
if (abc !== ARABIC)
|
|
2006
|
+
if (abc !== ALPHABET.ARABIC)
|
|
2007
2007
|
splitted = restoreCase(splitted, splittedOrig);
|
|
2008
2008
|
const nodeColors = nonHtml && nonHtml.nodeColors;
|
|
2009
2009
|
if (html || nodeColors)
|
|
@@ -2012,10 +2012,10 @@ var taraskSync = (text, options) => {
|
|
|
2012
2012
|
let gReplacer;
|
|
2013
2013
|
if (html) {
|
|
2014
2014
|
text = replaceWithDict(text, additionalReplacements[abc]);
|
|
2015
|
-
if (abc === CYRILLIC) {
|
|
2015
|
+
if (abc === ALPHABET.CYRILLIC) {
|
|
2016
2016
|
gReplacer = html.g ? apply.H("$&") : ($0) => apply.H(gobj[$0]);
|
|
2017
2017
|
}
|
|
2018
|
-
} else if (nonHtml && abc === CYRILLIC) {
|
|
2018
|
+
} else if (nonHtml && abc === ALPHABET.CYRILLIC) {
|
|
2019
2019
|
if (nonHtml.nodeColors) {
|
|
2020
2020
|
gReplacer = nonHtml.h ? ($0) => apply.H(gobj[$0]) : apply.H("$&");
|
|
2021
2021
|
} else if (nonHtml.h) {
|
|
@@ -2026,7 +2026,7 @@ var taraskSync = (text, options) => {
|
|
|
2026
2026
|
text = text.replace(G_REGEX, gReplacer);
|
|
2027
2027
|
if (noFix.length)
|
|
2028
2028
|
text = text.replace(NOFIX_REGEX, () => noFix.shift());
|
|
2029
|
-
return (html ? finalizer.html(text) : finalizer.nonHtml(text, nonHtml
|
|
2029
|
+
return (html ? finalizer.html(text) : finalizer.nonHtml(text, nonHtml)).trim();
|
|
2030
2030
|
};
|
|
2031
2031
|
var tarask = (...args) => new Promise((res) => res(taraskSync(...args)));
|
|
2032
2032
|
function restoreCase(text, orig) {
|
|
@@ -2065,15 +2065,15 @@ function toTags(text, orig, abc, applyF) {
|
|
|
2065
2065
|
continue;
|
|
2066
2066
|
if (!/\(/.test(word)) {
|
|
2067
2067
|
if (word.length === oWord.length) {
|
|
2068
|
-
const
|
|
2069
|
-
for (let
|
|
2070
|
-
if (
|
|
2071
|
-
|
|
2068
|
+
const wordLetters = word.split("");
|
|
2069
|
+
for (let j = 0; j < wordLetters.length; j++) {
|
|
2070
|
+
if (wordH[j] !== oWord[j])
|
|
2071
|
+
wordLetters[j] = applyF(wordLetters[j]);
|
|
2072
2072
|
}
|
|
2073
|
-
text[i] =
|
|
2073
|
+
text[i] = wordLetters.join("");
|
|
2074
2074
|
continue;
|
|
2075
2075
|
}
|
|
2076
|
-
if (abc === CYRILLIC) {
|
|
2076
|
+
if (abc === ALPHABET.CYRILLIC) {
|
|
2077
2077
|
const word1 = word.replace(/ь/g, "");
|
|
2078
2078
|
switch (oWord) {
|
|
2079
2079
|
case word1:
|
|
@@ -2144,19 +2144,22 @@ var finalizer = {
|
|
|
2144
2144
|
const main = options.shift();
|
|
2145
2145
|
return `<tarL data-l='${options}'>${main}</tarL>`;
|
|
2146
2146
|
}).replace(/ \n /g, "<br>"),
|
|
2147
|
-
nonHtml(text, options
|
|
2148
|
-
if (options && options.variations !==
|
|
2147
|
+
nonHtml(text, options) {
|
|
2148
|
+
if (options && options.variations !== VARIATION.ALL) {
|
|
2149
2149
|
const WORD_INDEX = options.variations;
|
|
2150
2150
|
const replacer = ($0) => $0.slice(1, -1).split("|")[WORD_INDEX];
|
|
2151
2151
|
text = text.replace(
|
|
2152
2152
|
OPTIONAL_WORDS_REGEX,
|
|
2153
|
-
options.nodeColors ? ($0) =>
|
|
2153
|
+
options.nodeColors ? ($0) => tagApplications.nonHtml.L(replacer($0)) : replacer
|
|
2154
2154
|
);
|
|
2155
2155
|
}
|
|
2156
2156
|
return text.replace(/(/g, "(");
|
|
2157
2157
|
}
|
|
2158
2158
|
};
|
|
2159
2159
|
export {
|
|
2160
|
+
ALPHABET,
|
|
2161
|
+
J,
|
|
2162
|
+
VARIATION,
|
|
2160
2163
|
gobj,
|
|
2161
2164
|
tarask,
|
|
2162
2165
|
taraskSync
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "taraskevizer",
|
|
3
3
|
"author": "GooseOb",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.3.0",
|
|
6
6
|
"private": false,
|
|
7
7
|
"homepage": "https://gooseob.github.io/taraskevizatar/",
|
|
8
8
|
"main": "dist/index.js",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"type": "git",
|
|
29
29
|
"url": "git+https://github.com/GooseOb/taraskevizer.git"
|
|
30
30
|
},
|
|
31
|
+
"description": "Канвэртацыя акадэмічнага правапісу ў клясычны",
|
|
31
32
|
"keywords": [
|
|
32
33
|
"taraskevizatar",
|
|
33
34
|
"taraskevica",
|