taraskevizer 10.2.1 → 10.2.5

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 @@ process.argv.splice(0, 2);
7
7
  const firstArg = process.argv[0];
8
8
  if (firstArg) {
9
9
  if (firstArg === '-v' || firstArg === '--version') {
10
- printWithPrefix("10.2.1");
10
+ printWithPrefix("10.2.5");
11
11
  process.exit(0);
12
12
  }
13
13
  if (firstArg === '-h' || firstArg === '--help') {
@@ -16,6 +16,11 @@ const common = {
16
16
  [/сь/g, 'ś'],
17
17
  [/нь/g, 'ń'],
18
18
  [/ль/g, 'l'],
19
+ [/лі/g, 'li'],
20
+ [/ля/g, 'la'],
21
+ [/лё/g, 'lo'],
22
+ [/лю/g, 'lu'],
23
+ [/ле/g, 'le'],
19
24
  [/а/g, 'a'],
20
25
  [/б/g, 'b'],
21
26
  [/в/g, 'v'],
@@ -48,8 +53,6 @@ const common = {
48
53
  [/э/g, 'e'],
49
54
  [/ю/g, 'iu'],
50
55
  [/я/g, 'ia'],
51
- [/łi(?=[eoua])/g, 'l'],
52
- [/łi/g, 'li'],
53
56
  ],
54
57
  ],
55
58
  upper: [
@@ -1577,5 +1577,4 @@ export const wordlist = callableDict([
1577
1577
  [/ зямель /g, ' з(ямель|емляў) '],
1578
1578
  [/ яблынь /g, ' яблын(ь|яў) '],
1579
1579
  [/ расей /g, ' расе(й|яў) '],
1580
- ]);
1581
- wordlist.value = wordlist.value.concat(commonPhonetic, gwords, iaWords.value, [[/\ue0ff/g, '']]);
1580
+ ].concat(commonPhonetic, gwords, iaWords.value, [[/\ue0ff/g, '']]));
@@ -2,7 +2,7 @@ import { replaceG } from './replace-g.js';
2
2
  import { gobj } from '../dict/index.js';
3
3
  const replaceGByOpposite = replaceG(($0) => gobj[$0]);
4
4
  export const highlightDiff = (text, orig, isCyrillic, highlight) => {
5
- for (let i = 0; i < text.length; i++) {
5
+ highlighting: for (let i = 0; i < text.length; i++) {
6
6
  const word = text[i];
7
7
  const oWord = orig[i];
8
8
  if (oWord === word)
@@ -10,14 +10,23 @@ export const highlightDiff = (text, orig, isCyrillic, highlight) => {
10
10
  const wordH = isCyrillic ? replaceGByOpposite(word) : word;
11
11
  if (oWord === wordH)
12
12
  continue;
13
- if (!/\(/.test(word)) {
13
+ if (!word.includes('(')) {
14
14
  if (word.length === oWord.length) {
15
- const wordLetters = word.split('');
16
- for (let j = 0; j < wordLetters.length; j++) {
17
- if (wordH[j] !== oWord[j])
18
- wordLetters[j] = highlight(wordLetters[j]);
15
+ text[i] = '';
16
+ let j = 0;
17
+ while (j < word.length) {
18
+ while (wordH[j] === oWord[j]) {
19
+ text[i] += word[j];
20
+ ++j;
21
+ if (j === word.length)
22
+ continue highlighting;
23
+ }
24
+ const first = j;
25
+ while (wordH[j] !== oWord[j] && j < word.length) {
26
+ ++j;
27
+ }
28
+ text[i] += highlight(word.slice(first, j));
19
29
  }
20
- text[i] = wordLetters.join('');
21
30
  continue;
22
31
  }
23
32
  if (isCyrillic) {
@@ -33,30 +42,38 @@ export const highlightDiff = (text, orig, isCyrillic, highlight) => {
33
42
  }
34
43
  }
35
44
  const oWordEnd = oWord.length - 1;
36
- let fromStart = 0;
37
- let fromWordEnd = word.length - 1;
38
- let fromOWordEnd = oWordEnd;
39
- while (wordH[fromStart] === oWord[fromStart])
40
- ++fromStart;
41
- while (wordH[fromWordEnd] === oWord[fromOWordEnd]) {
42
- --fromWordEnd;
43
- --fromOWordEnd;
45
+ let lastI = word.length - 1;
46
+ let lastOI = oWordEnd;
47
+ while (wordH[lastI] === oWord[lastOI]) {
48
+ --lastI;
49
+ --lastOI;
44
50
  }
45
- if (oWord.length < word.length) {
46
- if (fromOWordEnd === oWordEnd) {
47
- text[i] = highlight(word);
48
- continue;
49
- }
50
- if (fromWordEnd < 0)
51
- fromWordEnd = 0;
51
+ if (lastI < 1) {
52
+ // beginning removed -> first letter
53
+ text[i] = highlight(word[0]) + word.slice(1);
54
+ continue;
55
+ }
56
+ let firstI = 0;
57
+ while (wordH[firstI] === oWord[firstI])
58
+ ++firstI;
59
+ if (firstI === word.length) {
60
+ // ending removed -> last letter
61
+ text[i] = word.slice(0, lastI) + highlight(word[lastI]);
62
+ }
63
+ else if (firstI === 0 && lastOI === oWordEnd) {
64
+ // first and last letters changed -> whole word
65
+ text[i] = highlight(word);
66
+ continue;
52
67
  }
53
- if (fromStart === fromWordEnd + 1) {
54
- --fromStart;
55
- ++fromWordEnd;
68
+ ++lastI;
69
+ if (firstI === lastI) {
70
+ // part removed -> surrounding letters
71
+ --firstI;
72
+ ++lastI;
56
73
  }
57
74
  text[i] =
58
- word.slice(0, fromStart) +
59
- highlight(word.slice(fromStart, fromWordEnd + 1)) +
60
- word.slice(fromWordEnd + 1);
75
+ word.slice(0, firstI) +
76
+ highlight(word.slice(firstI, lastI)) +
77
+ word.slice(lastI);
61
78
  }
62
79
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taraskevizer",
3
- "version": "10.2.1",
3
+ "version": "10.2.5",
4
4
  "author": "GooseOb",
5
5
  "repository": {
6
6
  "type": "git",