bindu 1.6.0 → 1.7.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/ChangeLog +8 -0
- package/README.md +6 -1
- package/lib/bindu.js +7 -0
- package/lib/sandhi/apply-ayadaya/index.js +15 -25
- package/package.json +1 -1
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -27,7 +27,12 @@ npm i bindu -g
|
|
|
27
27
|
import {bindu} from 'bindu';
|
|
28
28
|
|
|
29
29
|
bindu('प्रतिएक');
|
|
30
|
-
// returns {code: 'प्रत्येक'
|
|
30
|
+
// returns {code: 'प्रत्येक'}
|
|
31
|
+
|
|
32
|
+
bindu('द्रौपदी अश्वम्', {
|
|
33
|
+
type: 'iast',
|
|
34
|
+
});
|
|
35
|
+
// returns {code: 'draupadyaśvam'}
|
|
31
36
|
|
|
32
37
|
const {places} = bindu('प्रतिएक', {
|
|
33
38
|
fix: false,
|
package/lib/bindu.js
CHANGED
|
@@ -5,6 +5,7 @@ import {postProcess, preProcess} from './process.js';
|
|
|
5
5
|
|
|
6
6
|
export const toSLP1 = (a) => Sanscript.t(a, 'devanagari', 'slp1');
|
|
7
7
|
export const toDevanagari = (a) => Sanscript.t(a, 'slp1', 'devanagari');
|
|
8
|
+
export const toIAST = (a) => Sanscript.t(a, 'slp1', 'iast');
|
|
8
9
|
|
|
9
10
|
export const bindu = (text, overrides = {}) => {
|
|
10
11
|
const {fix = true, type} = overrides;
|
|
@@ -25,6 +26,12 @@ export const bindu = (text, overrides = {}) => {
|
|
|
25
26
|
places,
|
|
26
27
|
};
|
|
27
28
|
|
|
29
|
+
if (type === 'iast')
|
|
30
|
+
return {
|
|
31
|
+
code: toIAST(cleanText),
|
|
32
|
+
places,
|
|
33
|
+
};
|
|
34
|
+
|
|
28
35
|
return {
|
|
29
36
|
code: toDevanagari(cleanText),
|
|
30
37
|
places,
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import {operator} from 'putout';
|
|
2
|
-
import {avagraha} from '../../symbols.js';
|
|
3
2
|
|
|
4
3
|
const {remove} = operator;
|
|
5
4
|
|
|
6
5
|
export const report = () => `ayādayaḥ`;
|
|
7
6
|
|
|
8
7
|
export const fix = ({path, next, name, nextName}) => {
|
|
9
|
-
const joint = createJoint(name, nextName);
|
|
10
|
-
|
|
11
|
-
path.node.name = `${name.slice(0, -1)}${joint}${nextName.slice(1)}`;
|
|
12
8
|
remove(next);
|
|
9
|
+
|
|
10
|
+
if (nextName.startsWith('a')) {
|
|
11
|
+
path.node.name = `${name}${nextName.slice(1)}`;
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (nextName.startsWith('ya')) {
|
|
16
|
+
path.node.name = `${name.slice(0, -1)}${nextName.slice(1)}`;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
path.node.name = `${name.slice(0, -1)}i${nextName.slice(1)}`;
|
|
13
21
|
};
|
|
14
22
|
|
|
15
23
|
export const traverse = ({push}) => ({
|
|
@@ -22,15 +30,10 @@ export const traverse = ({push}) => ({
|
|
|
22
30
|
const {name} = path.node;
|
|
23
31
|
const nextName = next.node.name;
|
|
24
32
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
.toLowerCase();
|
|
28
|
-
|
|
29
|
-
const first = nextName
|
|
30
|
-
.at(0)
|
|
31
|
-
.toLowerCase();
|
|
33
|
+
if (!name.endsWith('ya'))
|
|
34
|
+
return;
|
|
32
35
|
|
|
33
|
-
if (
|
|
36
|
+
if (!/^(i|a|ya)/.test(nextName))
|
|
34
37
|
return;
|
|
35
38
|
|
|
36
39
|
push({
|
|
@@ -41,16 +44,3 @@ export const traverse = ({push}) => ({
|
|
|
41
44
|
});
|
|
42
45
|
},
|
|
43
46
|
});
|
|
44
|
-
|
|
45
|
-
function createJoint(name, nextName) {
|
|
46
|
-
if (name.endsWith('a') && nextName.startsWith('e'))
|
|
47
|
-
return 'aye';
|
|
48
|
-
|
|
49
|
-
if (name.endsWith('a') && nextName.startsWith('o'))
|
|
50
|
-
return 'ayau';
|
|
51
|
-
|
|
52
|
-
if (name.endsWith('e') && nextName.startsWith('a'))
|
|
53
|
-
return `e${avagraha.code}`;
|
|
54
|
-
|
|
55
|
-
return '';
|
|
56
|
-
}
|