taraskevizer 10.2.1 → 10.2.4
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 +1 -1
- package/dist/dict/alphabets/latin.js +5 -2
- package/dist/dict/wordlist.js +1 -2
- package/dist/lib/highlight-diff.js +46 -28
- package/package.json +1 -1
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.
|
|
10
|
+
printWithPrefix("10.2.4");
|
|
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: [
|
package/dist/dict/wordlist.js
CHANGED
|
@@ -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,24 @@ export const highlightDiff = (text, orig, isCyrillic, highlight) => {
|
|
|
10
10
|
const wordH = isCyrillic ? replaceGByOpposite(word) : word;
|
|
11
11
|
if (oWord === wordH)
|
|
12
12
|
continue;
|
|
13
|
-
|
|
13
|
+
const noVariableParts = !/\(/.test(word);
|
|
14
|
+
if (noVariableParts) {
|
|
14
15
|
if (word.length === oWord.length) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
text[i] = '';
|
|
17
|
+
let j = 0;
|
|
18
|
+
while (j < word.length) {
|
|
19
|
+
while (wordH[j] === oWord[j]) {
|
|
20
|
+
text[i] += word[j];
|
|
21
|
+
++j;
|
|
22
|
+
if (j === word.length)
|
|
23
|
+
continue highlighting;
|
|
24
|
+
}
|
|
25
|
+
const first = j;
|
|
26
|
+
while (wordH[j] !== oWord[j] && j < word.length) {
|
|
27
|
+
++j;
|
|
28
|
+
}
|
|
29
|
+
text[i] += highlight(word.slice(first, j));
|
|
19
30
|
}
|
|
20
|
-
text[i] = wordLetters.join('');
|
|
21
31
|
continue;
|
|
22
32
|
}
|
|
23
33
|
if (isCyrillic) {
|
|
@@ -33,30 +43,38 @@ export const highlightDiff = (text, orig, isCyrillic, highlight) => {
|
|
|
33
43
|
}
|
|
34
44
|
}
|
|
35
45
|
const oWordEnd = oWord.length - 1;
|
|
36
|
-
let
|
|
37
|
-
let
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
while (wordH[fromWordEnd] === oWord[fromOWordEnd]) {
|
|
42
|
-
--fromWordEnd;
|
|
43
|
-
--fromOWordEnd;
|
|
46
|
+
let lastI = word.length - 1;
|
|
47
|
+
let lastOI = oWordEnd;
|
|
48
|
+
while (wordH[lastI] === oWord[lastOI]) {
|
|
49
|
+
--lastI;
|
|
50
|
+
--lastOI;
|
|
44
51
|
}
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
if (lastI < 1) {
|
|
53
|
+
// beginning removed -> first letter
|
|
54
|
+
text[i] = highlight(word[0]) + word.slice(1);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
let firstI = 0;
|
|
58
|
+
while (wordH[firstI] === oWord[firstI])
|
|
59
|
+
++firstI;
|
|
60
|
+
if (firstI === word.length) {
|
|
61
|
+
// ending removed -> last letter
|
|
62
|
+
text[i] = word.slice(0, lastI) + highlight(word[lastI]);
|
|
63
|
+
}
|
|
64
|
+
else if (firstI === 0 && lastOI === oWordEnd) {
|
|
65
|
+
// first and last letters changed -> whole word
|
|
66
|
+
text[i] = highlight(word);
|
|
67
|
+
continue;
|
|
52
68
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
69
|
+
++lastI;
|
|
70
|
+
if (firstI === lastI) {
|
|
71
|
+
// part removed -> surrounding letters
|
|
72
|
+
--firstI;
|
|
73
|
+
++lastI;
|
|
56
74
|
}
|
|
57
75
|
text[i] =
|
|
58
|
-
word.slice(0,
|
|
59
|
-
highlight(word.slice(
|
|
60
|
-
word.slice(
|
|
76
|
+
word.slice(0, firstI) +
|
|
77
|
+
highlight(word.slice(firstI, lastI)) +
|
|
78
|
+
word.slice(lastI);
|
|
61
79
|
}
|
|
62
80
|
};
|