taraskevizer 6.1.18 → 6.1.19

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/bin.js CHANGED
@@ -7,7 +7,7 @@ const printWithPrefix = (msg) => {
7
7
  process.argv.splice(0, 2);
8
8
  const checkForOptions = (options) => process.argv[0] && options.includes(process.argv[0].toLowerCase());
9
9
  if (checkForOptions(["-v", "--version"])) {
10
- printWithPrefix("6.1.18");
10
+ printWithPrefix("6.1.19");
11
11
  process.exit(0);
12
12
  }
13
13
  if (checkForOptions(["-h", "--help"])) {
package/dist/index.cjs CHANGED
@@ -327,7 +327,7 @@ var chemicalElements2 = [
327
327
  ];
328
328
  chemicalElements2[1] = chemicalElements2[0] + "|айнштайн|мендзялев|сыборг|гас|флеров";
329
329
  var chemicalElements3 = " гал|бэрыл|тул|бэркл|набэл";
330
- var ia = (word, words) => ` ${word} (?=\\(?(?:[бвгджзйклмнпстфцчшў]*[оё]|${words.replace(/\(/g, "(?:")}|i(?:${iwords})))`;
330
+ var ia = (word, words) => ` ${word}(?= \\(?(?:[бвгджзйклмнпстфцчшў]*[оё]|${words.replace(/\(/g, "(?:")}|i(?:${iwords})))`;
331
331
  var gwords = [
332
332
  " ґб ",
333
333
  "ґг",
@@ -1796,7 +1796,7 @@ var wordlist = dictFrom.raw([
1796
1796
  ўвод
1797
1797
  ўс[еёя]
1798
1798
  фарб(а(ў|мі)?|у|ы)?
1799
- ян `)), " ня "],
1799
+ ян `)), " ня"],
1800
1800
  /* без > бяз */
1801
1801
  [ia("без", toOneLine(`(вы)?(клад[ау]
1802
1802
  мела
@@ -1833,7 +1833,7 @@ var wordlist = dictFrom.raw([
1833
1833
  ўс[еёя]
1834
1834
  фарб(аў|ы)?
1835
1835
  цукр[ау]
1836
- ян`)), " бяз "],
1836
+ ян`)), " бяз"],
1837
1837
  /* іс */
1838
1838
  [/(\S)([іы]) (аа|ба|генэ|кры|тэ)зіс /, "$1($2|ая) $3(зіс|за) "],
1839
1839
  [/ага (аа|ба|генэ|кры|тэ)зіс[ау] /, "(ага|ай) $1(зісу|зы) "],
@@ -2246,9 +2246,8 @@ var resolveSpecialSyntax = (text, noFixArr, leftAngleBracket, convertAlphavet, d
2246
2246
  };
2247
2247
 
2248
2248
  // src/tarask.ts
2249
- var afterJoin = (text) => text.replace(/ /g, " ").replace(new RegExp(" (\\p{P}|\\p{S}|\\d|&#40) ", "gu"), "$1");
2250
- var join = (textArr) => afterJoin(textArr.join(" "));
2251
- var finalize = (text, newLine) => text.replace(/ \t /g, " ").replace(/ \n /g, newLine).trim();
2249
+ var afterJoin = (text) => text.replace(/ /g, " ").replace(new RegExp(" (\\p{P}|\\p{S}|\\d+|&#40) ", "gu"), "$1");
2250
+ var finalize = (text, newLine) => text.replace(/\n/g, newLine).trim();
2252
2251
  var restoreParentheses = (text) => text.replace(/&#40/g, "(");
2253
2252
  var wordlistPlusNoSoften = wordlist.concat(noSoften);
2254
2253
  var Taraskevizer = class {
@@ -2265,6 +2264,10 @@ var Taraskevizer = class {
2265
2264
  ansiColors: false,
2266
2265
  variations: VARIATION.ALL
2267
2266
  };
2267
+ spaces = [];
2268
+ restoreSpaces(text) {
2269
+ return text.replace(/ /g, () => this.spaces.shift());
2270
+ }
2268
2271
  constructor(options) {
2269
2272
  if (!options)
2270
2273
  return;
@@ -2283,7 +2286,7 @@ var Taraskevizer = class {
2283
2286
  );
2284
2287
  if (this.nonHtml.ansiColors)
2285
2288
  highlightDiff(splitted, splittedOrig, isCyrillic, wrapInColorOf.fix);
2286
- text = join(splitted);
2289
+ text = afterJoin(this.restoreSpaces(splitted.join(" ")));
2287
2290
  if (isCyrillic && (this.nonHtml.h || this.nonHtml.ansiColors))
2288
2291
  text = replaceG(
2289
2292
  text,
@@ -2306,7 +2309,7 @@ var Taraskevizer = class {
2306
2309
  this.prepare(text, noFixArr, "<")
2307
2310
  );
2308
2311
  highlightDiff(splitted, splittedOrig, isCyrillic, wrapInTag.fix);
2309
- text = join(splitted);
2312
+ text = afterJoin(this.restoreSpaces(splitted.join(" ")));
2310
2313
  if (isCyrillic)
2311
2314
  text = replaceG(
2312
2315
  text,
@@ -2321,9 +2324,8 @@ var Taraskevizer = class {
2321
2324
  );
2322
2325
  }
2323
2326
  prepare(text, noFixArr, LEFT_ANGLE_BRACKET, doEscapeCapitalized = this.general.doEscapeCapitalized) {
2324
- text = ` ${text.trim()} `.replace(//g, "");
2325
- return resolveSpecialSyntax(
2326
- text,
2327
+ text = resolveSpecialSyntax(
2328
+ ` ${text.trim()} `.replace(//g, ""),
2327
2329
  noFixArr,
2328
2330
  LEFT_ANGLE_BRACKET,
2329
2331
  (abcOnlyText) => restoreCase(
@@ -2334,7 +2336,12 @@ var Taraskevizer = class {
2334
2336
  abcOnlyText.split(" ")
2335
2337
  ).join(" "),
2336
2338
  doEscapeCapitalized
2337
- ).replace(/г'(?![еёіюя])/g, "ґ").replace(/ - /g, " — ").replace(new RegExp("([\\n\\t]|\\p{P}|\\p{S}|\\d)", "gu"), " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "&#40");
2339
+ ).replace(/г'(?![еёіюя])/g, "ґ").replace(/ - /g, " — ").replace(new RegExp("(\\p{P}|\\p{S}|\\d+)", "gu"), " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "&#40");
2340
+ text = text.replace(/\s+/g, (match) => {
2341
+ this.spaces.push(match);
2342
+ return " ";
2343
+ });
2344
+ return text;
2338
2345
  }
2339
2346
  convertAlphabetOnly(text) {
2340
2347
  const noFixArr = [];
@@ -2343,9 +2350,11 @@ var Taraskevizer = class {
2343
2350
  restoreParentheses(
2344
2351
  applyNoFix(
2345
2352
  noFixArr,
2346
- convertAlphabet(
2347
- this.prepare(text, noFixArr, "<", false),
2348
- this.general.abc
2353
+ this.restoreSpaces(
2354
+ convertAlphabet(
2355
+ this.prepare(text, noFixArr, "<", false),
2356
+ this.general.abc
2357
+ )
2349
2358
  )
2350
2359
  )
2351
2360
  )
package/dist/index.d.ts CHANGED
@@ -51,6 +51,8 @@ declare class Taraskevizer {
51
51
  ansiColors: boolean;
52
52
  variations: Variation;
53
53
  };
54
+ private spaces;
55
+ restoreSpaces(text: string): string;
54
56
  constructor(options?: DeepPartialReadonly<{
55
57
  general: TaraskOptions;
56
58
  html: HtmlOptions;
package/dist/index.js CHANGED
@@ -302,7 +302,7 @@ var chemicalElements2 = [
302
302
  ];
303
303
  chemicalElements2[1] = chemicalElements2[0] + "|айнштайн|мендзялев|сыборг|гас|флеров";
304
304
  var chemicalElements3 = " гал|бэрыл|тул|бэркл|набэл";
305
- var ia = (word, words) => ` ${word} (?=\\(?(?:[бвгджзйклмнпстфцчшў]*[оё]|${words.replace(/\(/g, "(?:")}|i(?:${iwords})))`;
305
+ var ia = (word, words) => ` ${word}(?= \\(?(?:[бвгджзйклмнпстфцчшў]*[оё]|${words.replace(/\(/g, "(?:")}|i(?:${iwords})))`;
306
306
  var gwords = [
307
307
  " ґб ",
308
308
  "ґг",
@@ -1771,7 +1771,7 @@ var wordlist = dictFrom.raw([
1771
1771
  ўвод
1772
1772
  ўс[еёя]
1773
1773
  фарб(а(ў|мі)?|у|ы)?
1774
- ян `)), " ня "],
1774
+ ян `)), " ня"],
1775
1775
  /* без > бяз */
1776
1776
  [ia("без", toOneLine(`(вы)?(клад[ау]
1777
1777
  мела
@@ -1808,7 +1808,7 @@ var wordlist = dictFrom.raw([
1808
1808
  ўс[еёя]
1809
1809
  фарб(аў|ы)?
1810
1810
  цукр[ау]
1811
- ян`)), " бяз "],
1811
+ ян`)), " бяз"],
1812
1812
  /* іс */
1813
1813
  [/(\S)([іы]) (аа|ба|генэ|кры|тэ)зіс /, "$1($2|ая) $3(зіс|за) "],
1814
1814
  [/ага (аа|ба|генэ|кры|тэ)зіс[ау] /, "(ага|ай) $1(зісу|зы) "],
@@ -2221,9 +2221,8 @@ var resolveSpecialSyntax = (text, noFixArr, leftAngleBracket, convertAlphavet, d
2221
2221
  };
2222
2222
 
2223
2223
  // src/tarask.ts
2224
- var afterJoin = (text) => text.replace(/&nbsp;/g, " ").replace(new RegExp(" (\\p{P}|\\p{S}|\\d|&#40) ", "gu"), "$1");
2225
- var join = (textArr) => afterJoin(textArr.join(" "));
2226
- var finalize = (text, newLine) => text.replace(/ \t /g, " ").replace(/ \n /g, newLine).trim();
2224
+ var afterJoin = (text) => text.replace(/&nbsp;/g, " ").replace(new RegExp(" (\\p{P}|\\p{S}|\\d+|&#40) ", "gu"), "$1");
2225
+ var finalize = (text, newLine) => text.replace(/\n/g, newLine).trim();
2227
2226
  var restoreParentheses = (text) => text.replace(/&#40/g, "(");
2228
2227
  var wordlistPlusNoSoften = wordlist.concat(noSoften);
2229
2228
  var Taraskevizer = class {
@@ -2240,6 +2239,10 @@ var Taraskevizer = class {
2240
2239
  ansiColors: false,
2241
2240
  variations: VARIATION.ALL
2242
2241
  };
2242
+ spaces = [];
2243
+ restoreSpaces(text) {
2244
+ return text.replace(/ /g, () => this.spaces.shift());
2245
+ }
2243
2246
  constructor(options) {
2244
2247
  if (!options)
2245
2248
  return;
@@ -2258,7 +2261,7 @@ var Taraskevizer = class {
2258
2261
  );
2259
2262
  if (this.nonHtml.ansiColors)
2260
2263
  highlightDiff(splitted, splittedOrig, isCyrillic, wrapInColorOf.fix);
2261
- text = join(splitted);
2264
+ text = afterJoin(this.restoreSpaces(splitted.join(" ")));
2262
2265
  if (isCyrillic && (this.nonHtml.h || this.nonHtml.ansiColors))
2263
2266
  text = replaceG(
2264
2267
  text,
@@ -2281,7 +2284,7 @@ var Taraskevizer = class {
2281
2284
  this.prepare(text, noFixArr, "&lt;")
2282
2285
  );
2283
2286
  highlightDiff(splitted, splittedOrig, isCyrillic, wrapInTag.fix);
2284
- text = join(splitted);
2287
+ text = afterJoin(this.restoreSpaces(splitted.join(" ")));
2285
2288
  if (isCyrillic)
2286
2289
  text = replaceG(
2287
2290
  text,
@@ -2296,9 +2299,8 @@ var Taraskevizer = class {
2296
2299
  );
2297
2300
  }
2298
2301
  prepare(text, noFixArr, LEFT_ANGLE_BRACKET, doEscapeCapitalized = this.general.doEscapeCapitalized) {
2299
- text = ` ${text.trim()} `.replace(//g, "");
2300
- return resolveSpecialSyntax(
2301
- text,
2302
+ text = resolveSpecialSyntax(
2303
+ ` ${text.trim()} `.replace(//g, ""),
2302
2304
  noFixArr,
2303
2305
  LEFT_ANGLE_BRACKET,
2304
2306
  (abcOnlyText) => restoreCase(
@@ -2309,7 +2311,12 @@ var Taraskevizer = class {
2309
2311
  abcOnlyText.split(" ")
2310
2312
  ).join(" "),
2311
2313
  doEscapeCapitalized
2312
- ).replace(/г'(?![еёіюя])/g, "ґ").replace(/ - /g, " — ").replace(new RegExp("([\\n\\t]|\\p{P}|\\p{S}|\\d)", "gu"), " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "&#40");
2314
+ ).replace(/г'(?![еёіюя])/g, "ґ").replace(/ - /g, " — ").replace(new RegExp("(\\p{P}|\\p{S}|\\d+)", "gu"), " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "&#40");
2315
+ text = text.replace(/\s+/g, (match) => {
2316
+ this.spaces.push(match);
2317
+ return " ";
2318
+ });
2319
+ return text;
2313
2320
  }
2314
2321
  convertAlphabetOnly(text) {
2315
2322
  const noFixArr = [];
@@ -2318,9 +2325,11 @@ var Taraskevizer = class {
2318
2325
  restoreParentheses(
2319
2326
  applyNoFix(
2320
2327
  noFixArr,
2321
- convertAlphabet(
2322
- this.prepare(text, noFixArr, "<", false),
2323
- this.general.abc
2328
+ this.restoreSpaces(
2329
+ convertAlphabet(
2330
+ this.prepare(text, noFixArr, "<", false),
2331
+ this.general.abc
2332
+ )
2324
2333
  )
2325
2334
  )
2326
2335
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taraskevizer",
3
- "version": "6.1.18",
3
+ "version": "6.1.19",
4
4
  "author": "GooseOb",
5
5
  "repository": {
6
6
  "type": "git",