taraskevizer 5.3.3 → 6.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 CHANGED
@@ -53,7 +53,7 @@ taraskevizer.convertToHtml('энергія планеты');
53
53
  // "en<tarF>erg</tarF>ija p<tarF>lan</tarF>ety"
54
54
 
55
55
  // properties can be rewritten after creating an object
56
- taraskevizer.abc = ALPHABET.ARABIC;
56
+ taraskevizer.general.abc = ALPHABET.ARABIC;
57
57
  taraskevizer.html.g = true;
58
58
 
59
59
  const latinizerWithJi = new Taraskevizer({
@@ -108,13 +108,13 @@ If set to false, may cause unwanted changes in acronyms.
108
108
 
109
109
  Is always `true` in `convertAlphabetOnly`.
110
110
 
111
- ### OVERRIDE_taraskevize
111
+ ### taraskevize
112
112
 
113
113
  Type: `(text: string) => string`
114
114
 
115
115
  Default value: internal function `taraskevize`
116
116
 
117
- Can be overridden in order to make additional changes to the text.
117
+ Overriddes internal function in order to change behaviour of taraskevization.
118
118
  This function usually uses private api via `__tarask__`
119
119
 
120
120
  ## html
package/dist/index.cjs CHANGED
@@ -2174,9 +2174,11 @@ var __tarask__ = {
2174
2174
  };
2175
2175
  var convertAlphabet = (text, abc) => replaceWithDict(replaceWithDict(text, letters[abc]), lettersUpperCase[abc]);
2176
2176
  var Taraskevizer = class {
2177
- abc = ALPHABET.CYRILLIC;
2178
- j = REPLACE_J.NEVER;
2179
- doEscapeCapitalized = true;
2177
+ general = {
2178
+ abc: ALPHABET.CYRILLIC,
2179
+ j: REPLACE_J.NEVER,
2180
+ doEscapeCapitalized: true
2181
+ };
2180
2182
  html = {
2181
2183
  g: false
2182
2184
  };
@@ -2188,24 +2190,13 @@ var Taraskevizer = class {
2188
2190
  constructor(options) {
2189
2191
  if (!options)
2190
2192
  return;
2191
- const general = options.general;
2192
- if (general) {
2193
- for (const prop of [
2194
- "abc",
2195
- "j",
2196
- "doEscapeCapitalized"
2197
- ])
2198
- if (prop in general)
2199
- this[prop] = general[prop];
2200
- }
2201
- if (options.OVERRIDE_taraskevize)
2202
- this.taraskevize = options.OVERRIDE_taraskevize;
2193
+ Object.assign(this.general, options.general);
2203
2194
  Object.assign(this.html, options.html);
2204
2195
  Object.assign(this.nonHtml, options.nonHtml);
2205
2196
  }
2206
2197
  convert(text) {
2207
2198
  const wrapInColorOf = wrappers.ansiColors;
2208
- const isCyrillic = this.abc === ALPHABET.CYRILLIC;
2199
+ const isCyrillic = this.general.abc === ALPHABET.CYRILLIC;
2209
2200
  const noFixArr = [];
2210
2201
  const { splitted, splittedOrig } = this.process(
2211
2202
  this.prepare(text, noFixArr, "<")
@@ -2230,7 +2221,7 @@ var Taraskevizer = class {
2230
2221
  }
2231
2222
  convertToHtml(text) {
2232
2223
  const wrapInTag = wrappers.html;
2233
- const isCyrillic = this.abc === ALPHABET.CYRILLIC;
2224
+ const isCyrillic = this.general.abc === ALPHABET.CYRILLIC;
2234
2225
  const noFixArr = [];
2235
2226
  const { splitted, splittedOrig } = this.process(
2236
2227
  this.prepare(text, noFixArr, "&lt;")
@@ -2251,7 +2242,7 @@ var Taraskevizer = class {
2251
2242
  "<br>"
2252
2243
  );
2253
2244
  }
2254
- prepare(text, noFixArr, LEFT_ANGLE_BRACKET, doEscapeCapitalized = this.doEscapeCapitalized) {
2245
+ prepare(text, noFixArr, LEFT_ANGLE_BRACKET, doEscapeCapitalized = this.general.doEscapeCapitalized) {
2255
2246
  text = ` ${text.trim()} `.replace(//g, "");
2256
2247
  if (doEscapeCapitalized)
2257
2248
  text = text.replace(
@@ -2263,7 +2254,7 @@ var Taraskevizer = class {
2263
2254
  return LEFT_ANGLE_BRACKET + $3 + ">";
2264
2255
  if ($1)
2265
2256
  $3 = restoreCase(
2266
- [replaceWithDict($3.toLowerCase(), letters[this.abc])],
2257
+ [replaceWithDict($3.toLowerCase(), letters[this.general.abc])],
2267
2258
  [$3]
2268
2259
  );
2269
2260
  noFixArr.push($2 === "." ? $3 : LEFT_ANGLE_BRACKET + $3 + ">");
@@ -2275,13 +2266,16 @@ var Taraskevizer = class {
2275
2266
  return finalize(
2276
2267
  applyNoFix(
2277
2268
  noFixArr,
2278
- convertAlphabet(this.prepare(text, noFixArr, "<", false), this.abc)
2269
+ convertAlphabet(
2270
+ this.prepare(text, noFixArr, "<", false),
2271
+ this.general.abc
2272
+ )
2279
2273
  ).replace(/&nbsp;/g, " ").replace(new RegExp(" (\\p{P}|\\p{S}|\\d|&#40) ", "gu"), "$1"),
2280
2274
  "\n"
2281
2275
  );
2282
2276
  }
2283
2277
  process(text) {
2284
- const { abc, j } = this;
2278
+ const { abc, j } = this.general;
2285
2279
  const splittedOrig = convertAlphabet(text, abc).split(" ");
2286
2280
  text = this.taraskevize(text.toLowerCase());
2287
2281
  if (j && abc !== ALPHABET.LATIN_JI)
package/dist/index.d.ts CHANGED
@@ -47,9 +47,11 @@ declare const __tarask__: {
47
47
  readonly afterTarask: ExtendedDict;
48
48
  };
49
49
  declare class Taraskevizer {
50
- abc: Alphabet;
51
- j: OptionJ;
52
- doEscapeCapitalized: boolean;
50
+ general: {
51
+ abc: Alphabet;
52
+ j: OptionJ;
53
+ doEscapeCapitalized: boolean;
54
+ };
53
55
  html: {
54
56
  g: boolean;
55
57
  };
package/dist/index.js CHANGED
@@ -2143,9 +2143,11 @@ var __tarask__ = {
2143
2143
  };
2144
2144
  var convertAlphabet = (text, abc) => replaceWithDict(replaceWithDict(text, letters[abc]), lettersUpperCase[abc]);
2145
2145
  var Taraskevizer = class {
2146
- abc = ALPHABET.CYRILLIC;
2147
- j = REPLACE_J.NEVER;
2148
- doEscapeCapitalized = true;
2146
+ general = {
2147
+ abc: ALPHABET.CYRILLIC,
2148
+ j: REPLACE_J.NEVER,
2149
+ doEscapeCapitalized: true
2150
+ };
2149
2151
  html = {
2150
2152
  g: false
2151
2153
  };
@@ -2157,24 +2159,13 @@ var Taraskevizer = class {
2157
2159
  constructor(options) {
2158
2160
  if (!options)
2159
2161
  return;
2160
- const general = options.general;
2161
- if (general) {
2162
- for (const prop of [
2163
- "abc",
2164
- "j",
2165
- "doEscapeCapitalized"
2166
- ])
2167
- if (prop in general)
2168
- this[prop] = general[prop];
2169
- }
2170
- if (options.OVERRIDE_taraskevize)
2171
- this.taraskevize = options.OVERRIDE_taraskevize;
2162
+ Object.assign(this.general, options.general);
2172
2163
  Object.assign(this.html, options.html);
2173
2164
  Object.assign(this.nonHtml, options.nonHtml);
2174
2165
  }
2175
2166
  convert(text) {
2176
2167
  const wrapInColorOf = wrappers.ansiColors;
2177
- const isCyrillic = this.abc === ALPHABET.CYRILLIC;
2168
+ const isCyrillic = this.general.abc === ALPHABET.CYRILLIC;
2178
2169
  const noFixArr = [];
2179
2170
  const { splitted, splittedOrig } = this.process(
2180
2171
  this.prepare(text, noFixArr, "<")
@@ -2199,7 +2190,7 @@ var Taraskevizer = class {
2199
2190
  }
2200
2191
  convertToHtml(text) {
2201
2192
  const wrapInTag = wrappers.html;
2202
- const isCyrillic = this.abc === ALPHABET.CYRILLIC;
2193
+ const isCyrillic = this.general.abc === ALPHABET.CYRILLIC;
2203
2194
  const noFixArr = [];
2204
2195
  const { splitted, splittedOrig } = this.process(
2205
2196
  this.prepare(text, noFixArr, "&lt;")
@@ -2220,7 +2211,7 @@ var Taraskevizer = class {
2220
2211
  "<br>"
2221
2212
  );
2222
2213
  }
2223
- prepare(text, noFixArr, LEFT_ANGLE_BRACKET, doEscapeCapitalized = this.doEscapeCapitalized) {
2214
+ prepare(text, noFixArr, LEFT_ANGLE_BRACKET, doEscapeCapitalized = this.general.doEscapeCapitalized) {
2224
2215
  text = ` ${text.trim()} `.replace(//g, "");
2225
2216
  if (doEscapeCapitalized)
2226
2217
  text = text.replace(
@@ -2232,7 +2223,7 @@ var Taraskevizer = class {
2232
2223
  return LEFT_ANGLE_BRACKET + $3 + ">";
2233
2224
  if ($1)
2234
2225
  $3 = restoreCase(
2235
- [replaceWithDict($3.toLowerCase(), letters[this.abc])],
2226
+ [replaceWithDict($3.toLowerCase(), letters[this.general.abc])],
2236
2227
  [$3]
2237
2228
  );
2238
2229
  noFixArr.push($2 === "." ? $3 : LEFT_ANGLE_BRACKET + $3 + ">");
@@ -2244,13 +2235,16 @@ var Taraskevizer = class {
2244
2235
  return finalize(
2245
2236
  applyNoFix(
2246
2237
  noFixArr,
2247
- convertAlphabet(this.prepare(text, noFixArr, "<", false), this.abc)
2238
+ convertAlphabet(
2239
+ this.prepare(text, noFixArr, "<", false),
2240
+ this.general.abc
2241
+ )
2248
2242
  ).replace(/&nbsp;/g, " ").replace(new RegExp(" (\\p{P}|\\p{S}|\\d|&#40) ", "gu"), "$1"),
2249
2243
  "\n"
2250
2244
  );
2251
2245
  }
2252
2246
  process(text) {
2253
- const { abc, j } = this;
2247
+ const { abc, j } = this.general;
2254
2248
  const splittedOrig = convertAlphabet(text, abc).split(" ");
2255
2249
  text = this.taraskevize(text.toLowerCase());
2256
2250
  if (j && abc !== ALPHABET.LATIN_JI)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taraskevizer",
3
- "version": "5.3.3",
3
+ "version": "6.0.0",
4
4
  "author": "GooseOb",
5
5
  "repository": {
6
6
  "type": "git",