bitaboom 1.0.0 → 1.1.1
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 +40 -1
- package/dist/index.d.ts +13 -0
- package/dist/main.js +237 -229
- package/dist/main.js.map +1 -1
- package/package.json +19 -23
package/README.md
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
# Table of Contents
|
|
2
2
|
|
|
3
|
-
[](https://wakatime.com/badge/user/a0b906ce-b8e7-4463-8bce-383238df6d4b/project/4a00f7dd-3a49-4d59-a2ff-43c89e22d650)
|
|
3
|
+
[](https://wakatime.com/badge/user/a0b906ce-b8e7-4463-8bce-383238df6d4b/project/4a00f7dd-3a49-4d59-a2ff-43c89e22d650)
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
[](https://codecov.io/gh/ragaeeb/bitaboom)
|
|
11
|
+
[](https://bundlejs.com/?q=bitaboom%40latest)
|
|
12
|
+

|
|
4
13
|
|
|
5
14
|
# Bitaboom - A String Utilities Library
|
|
6
15
|
|
|
7
16
|
Bitaboom is a NodeJS string utility library written in TypeScript, designed to provide a collection of helpful string manipulation functions. It supports the latest ESNext features and is tested using Vitest.
|
|
8
17
|
|
|
18
|
+
## Demo
|
|
19
|
+
|
|
20
|
+
[Demo](https://ragaeeb.github.io/bitaboom/)
|
|
21
|
+
|
|
9
22
|
## Installation
|
|
10
23
|
|
|
11
24
|
To install Bitaboom, use npm or yarn:
|
|
@@ -187,6 +200,19 @@ fixTrailingWow('السلام عليكم و رحمة');
|
|
|
187
200
|
|
|
188
201
|
---
|
|
189
202
|
|
|
203
|
+
### `hasWordInSingleLine`
|
|
204
|
+
|
|
205
|
+
Checks if a line has any word by itself.
|
|
206
|
+
|
|
207
|
+
#### Example:
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
hasWordInSingleLine('Abc efg\nhij\nklmn opq');
|
|
211
|
+
// Output: true (since "hij" is by itself)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
190
216
|
### `insertLineBreaksAfterPunctuation`
|
|
191
217
|
|
|
192
218
|
Adds line breaks after punctuation marks such as periods, exclamation points, and question marks.
|
|
@@ -407,6 +433,19 @@ removeSolitaryArabicLetters('ب ا الكلمات ت');
|
|
|
407
433
|
|
|
408
434
|
---
|
|
409
435
|
|
|
436
|
+
### `removeTatwil`
|
|
437
|
+
|
|
438
|
+
Removes tatweel characters from Arabic text while preserving the Hijri years.
|
|
439
|
+
|
|
440
|
+
#### Example:
|
|
441
|
+
|
|
442
|
+
```javascript
|
|
443
|
+
removeTatwil('أبـــتِـــكَةُ');
|
|
444
|
+
// Output: 'أبتِكَةُ'
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
---
|
|
448
|
+
|
|
410
449
|
### `removeUrls`
|
|
411
450
|
|
|
412
451
|
Removes URLs from the text.
|
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,13 @@ export const removeSingularCodes: (text: string) => string;
|
|
|
56
56
|
* @returns {string} - The modified text with solitary Arabic letters removed.
|
|
57
57
|
*/
|
|
58
58
|
export const removeSolitaryArabicLetters: (text: string) => string;
|
|
59
|
+
/**
|
|
60
|
+
* Removes tatweel characters while preserving dates references.
|
|
61
|
+
* Example: "1435/3/29 هـ" remains as "1435/3/29 هـ" but "أبـــتِـــكَةُ" becomes "أبتِكَةُ"
|
|
62
|
+
* @param text The text to format.
|
|
63
|
+
* @returns The modified text with the tatweel characters removed.
|
|
64
|
+
*/
|
|
65
|
+
export const removeTatwil: (text: string) => string;
|
|
59
66
|
/**
|
|
60
67
|
* Replaces the 'tah marbutah' (ة) character with 'ha' (ه).
|
|
61
68
|
* Example: 'مدرسة' will be changed to 'مدرسه'.
|
|
@@ -134,6 +141,12 @@ export const cleanLiteralNewLines: (text: string) => string;
|
|
|
134
141
|
* @returns {string} - The modified text with trailing spaces removed.
|
|
135
142
|
*/
|
|
136
143
|
export const cleanMultilines: (text: string) => string;
|
|
144
|
+
/**
|
|
145
|
+
* Detects if a word is by itself in a line.
|
|
146
|
+
* @param text The text to check.
|
|
147
|
+
* @returns true if there exists a word in any of the lines in the text that is by itself.
|
|
148
|
+
*/
|
|
149
|
+
export const hasWordInSingleLine: (text: string) => boolean;
|
|
137
150
|
/**
|
|
138
151
|
* Checks if the input string consists of only punctuation characters.
|
|
139
152
|
* @param {string} text - The input text to check.
|
package/dist/main.js
CHANGED
|
@@ -2,169 +2,177 @@
|
|
|
2
2
|
function $parcel$export(e, n, v, s) {
|
|
3
3
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
4
4
|
}
|
|
5
|
-
var $
|
|
5
|
+
var $28624456cd7e4cb8$exports = {};
|
|
6
6
|
|
|
7
|
-
$parcel$export($
|
|
8
|
-
$parcel$export($
|
|
9
|
-
$parcel$export($
|
|
10
|
-
$parcel$export($
|
|
11
|
-
$parcel$export($
|
|
12
|
-
$parcel$export($
|
|
13
|
-
$parcel$export($
|
|
14
|
-
$parcel$export($
|
|
15
|
-
$parcel$export($
|
|
16
|
-
$parcel$export($
|
|
17
|
-
$parcel$export($
|
|
18
|
-
$parcel$export($
|
|
19
|
-
$parcel$export($
|
|
20
|
-
$parcel$export($
|
|
7
|
+
$parcel$export($28624456cd7e4cb8$exports, "cleanExtremeArabicUnderscores", () => $28624456cd7e4cb8$export$60dc7fb96c441688);
|
|
8
|
+
$parcel$export($28624456cd7e4cb8$exports, "convertUrduSymbolsToArabic", () => $28624456cd7e4cb8$export$dcf00cfaf31fd188);
|
|
9
|
+
$parcel$export($28624456cd7e4cb8$exports, "fixTrailingWow", () => $28624456cd7e4cb8$export$6c58e29008d10c1d);
|
|
10
|
+
$parcel$export($28624456cd7e4cb8$exports, "addSpaceBetweenArabicTextAndNumbers", () => $28624456cd7e4cb8$export$cf81487e80b00e26);
|
|
11
|
+
$parcel$export($28624456cd7e4cb8$exports, "stripEnglishCharactersAndSymbols", () => $28624456cd7e4cb8$export$df81ab2e9352ca65);
|
|
12
|
+
$parcel$export($28624456cd7e4cb8$exports, "removeNonIndexSignatures", () => $28624456cd7e4cb8$export$d580a3cb14401529);
|
|
13
|
+
$parcel$export($28624456cd7e4cb8$exports, "removeSingularCodes", () => $28624456cd7e4cb8$export$84d849da647fa2e5);
|
|
14
|
+
$parcel$export($28624456cd7e4cb8$exports, "removeSolitaryArabicLetters", () => $28624456cd7e4cb8$export$7dedbc726019ed0f);
|
|
15
|
+
$parcel$export($28624456cd7e4cb8$exports, "removeTatwil", () => $28624456cd7e4cb8$export$9571c9c2c203652d);
|
|
16
|
+
$parcel$export($28624456cd7e4cb8$exports, "replaceTaMarbutahWithHa", () => $28624456cd7e4cb8$export$f95230335378ec58);
|
|
17
|
+
$parcel$export($28624456cd7e4cb8$exports, "stripDiacritics", () => $28624456cd7e4cb8$export$b5bee4b27048330b);
|
|
18
|
+
$parcel$export($28624456cd7e4cb8$exports, "stripZeroWidthCharacters", () => $28624456cd7e4cb8$export$8696bb09194c5fb5);
|
|
19
|
+
$parcel$export($28624456cd7e4cb8$exports, "replaceAlifMaqsurah", () => $28624456cd7e4cb8$export$b1d6cb321dee12ad);
|
|
20
|
+
$parcel$export($28624456cd7e4cb8$exports, "replaceEnglishPunctuationWithArabic", () => $28624456cd7e4cb8$export$db0c96cd03237332);
|
|
21
|
+
$parcel$export($28624456cd7e4cb8$exports, "normalizeAlifVariants", () => $28624456cd7e4cb8$export$1d28b07894af8a98);
|
|
21
22
|
/**
|
|
22
23
|
* Removes extreme Arabic underscores (ـ) that appear at the beginning or end of a line or in text.
|
|
23
24
|
* Does not affect Hijri dates (e.g., 1424هـ) or specific Arabic terms.
|
|
24
25
|
* Example: "ـThis is a textـ" will be changed to "This is a text".
|
|
25
26
|
* @param {string} text - The input text to apply the rule to.
|
|
26
27
|
* @returns {string} - The modified text with extreme underscores removed.
|
|
27
|
-
*/ const $
|
|
28
|
-
return text.replace(/(?<!\d ?ه|اه)ـ(?=\r?$)|^ـ(?!اهـ)/gm,
|
|
28
|
+
*/ const $28624456cd7e4cb8$export$60dc7fb96c441688 = (text)=>{
|
|
29
|
+
return text.replace(/(?<!\d ?ه|اه)ـ(?=\r?$)|^ـ(?!اهـ)/gm, '');
|
|
29
30
|
};
|
|
30
|
-
const $
|
|
31
|
+
const $28624456cd7e4cb8$export$dcf00cfaf31fd188 = (text)=>{
|
|
31
32
|
return text.replace(/ھ/g, "\u0647").replace(/ی/g, "\u064A");
|
|
32
33
|
};
|
|
33
|
-
const $
|
|
34
|
+
const $28624456cd7e4cb8$export$6c58e29008d10c1d = (text)=>{
|
|
34
35
|
return text.replace(/ و /g, " \u0648");
|
|
35
36
|
};
|
|
36
|
-
const $
|
|
37
|
-
return text.replace(/([\u0600-\u06FF]+)(\d+)/g,
|
|
37
|
+
const $28624456cd7e4cb8$export$cf81487e80b00e26 = (text)=>{
|
|
38
|
+
return text.replace(/([\u0600-\u06FF]+)(\d+)/g, '$1 $2');
|
|
38
39
|
};
|
|
39
|
-
const $
|
|
40
|
-
return text.replace(/[a-zA-Z]+[0-9]*|[¬§`ﷺ=]|\/{2,}|&/g,
|
|
40
|
+
const $28624456cd7e4cb8$export$df81ab2e9352ca65 = (text)=>{
|
|
41
|
+
return text.replace(/[a-zA-Z]+[0-9]*|[¬§`ﷺ=]|\/{2,}|&/g, ' ');
|
|
41
42
|
};
|
|
42
|
-
const $
|
|
43
|
-
return text.replace(/(?<![0-9] ?)-|(?<=[\u0600-\u06FF])\s?\d\s?(?=[\u0600-\u06FF])/g,
|
|
43
|
+
const $28624456cd7e4cb8$export$d580a3cb14401529 = (text)=>{
|
|
44
|
+
return text.replace(/(?<![0-9] ?)-|(?<=[\u0600-\u06FF])\s?\d\s?(?=[\u0600-\u06FF])/g, ' ').replace(/(?<=[\u0600-\u06FF]\s)(\d+\s)+\d+(?=(\s[\u0600-\u06FF]|$))/g, ' ');
|
|
44
45
|
};
|
|
45
|
-
const $
|
|
46
|
-
return text.replace(/[\[\({][\u0621-\u064A\u0660-\u0669][\]\)}]/g,
|
|
46
|
+
const $28624456cd7e4cb8$export$84d849da647fa2e5 = (text)=>{
|
|
47
|
+
return text.replace(/[\[\({][\u0621-\u064A\u0660-\u0669][\]\)}]/g, '');
|
|
47
48
|
};
|
|
48
|
-
const $
|
|
49
|
-
return text.replace(/(^| )[\u0621-\u064A]( |$)/g,
|
|
49
|
+
const $28624456cd7e4cb8$export$7dedbc726019ed0f = (text)=>{
|
|
50
|
+
return text.replace(/(^| )[\u0621-\u064A]( |$)/g, ' ');
|
|
50
51
|
};
|
|
51
|
-
const $
|
|
52
|
+
const $28624456cd7e4cb8$export$9571c9c2c203652d = (text)=>{
|
|
53
|
+
return text.replace(/(?<![0-9ه])ـ/g, '');
|
|
54
|
+
};
|
|
55
|
+
const $28624456cd7e4cb8$export$f95230335378ec58 = (text)=>{
|
|
52
56
|
return text.replace(/[ة]/g, "\u0647");
|
|
53
57
|
};
|
|
54
|
-
const $
|
|
55
|
-
return text.replace(/[\u0610\u0611\u0612\u0613\u0614\u0615\u0616\u0617\u0618\u0619\u061A\u064B\u064C\u064D\u064E\u064F\u0650\u0651\u0652\u0653\u0654\u0655\u0656\u0657\u0658\u065A\u065B\u065C\u065D\u065E\u0640]/g,
|
|
58
|
+
const $28624456cd7e4cb8$export$b5bee4b27048330b = (text)=>{
|
|
59
|
+
return text.replace(/[\u0610\u0611\u0612\u0613\u0614\u0615\u0616\u0617\u0618\u0619\u061A\u064B\u064C\u064D\u064E\u064F\u0650\u0651\u0652\u0653\u0654\u0655\u0656\u0657\u0658\u065A\u065B\u065C\u065D\u065E\u0640]/g, '');
|
|
56
60
|
};
|
|
57
|
-
const $
|
|
58
|
-
return text.replace(/[\u200B-\u200F\u202A-\u202E\u2060-\u2064\uFEFF]/g,
|
|
61
|
+
const $28624456cd7e4cb8$export$8696bb09194c5fb5 = (text)=>{
|
|
62
|
+
return text.replace(/[\u200B-\u200F\u202A-\u202E\u2060-\u2064\uFEFF]/g, ' ');
|
|
59
63
|
};
|
|
60
|
-
const $
|
|
64
|
+
const $28624456cd7e4cb8$export$b1d6cb321dee12ad = (text)=>{
|
|
61
65
|
return text.replace(/[ىي]/g, "\u064A");
|
|
62
66
|
};
|
|
63
|
-
const $
|
|
67
|
+
const $28624456cd7e4cb8$export$db0c96cd03237332 = (text)=>{
|
|
64
68
|
return text.replace(/\?|؟\./g, "\u061F").replace(/(;|؛)\s*(\1\s*)*/g, "\u061B").replace(/,|-،/g, "\u060C");
|
|
65
69
|
};
|
|
66
|
-
const $
|
|
70
|
+
const $28624456cd7e4cb8$export$1d28b07894af8a98 = (text)=>{
|
|
67
71
|
return text.replace(/[أإآ]/g, "\u0627");
|
|
68
72
|
};
|
|
69
73
|
|
|
70
74
|
|
|
71
|
-
var $
|
|
75
|
+
var $f4495ebb65d3b1e0$exports = {};
|
|
72
76
|
|
|
73
|
-
$parcel$export($
|
|
74
|
-
$parcel$export($
|
|
75
|
-
$parcel$export($
|
|
76
|
-
$parcel$export($
|
|
77
|
-
$parcel$export($
|
|
78
|
-
$parcel$export($
|
|
79
|
-
$parcel$export($
|
|
80
|
-
$parcel$export($
|
|
81
|
-
$parcel$export($
|
|
82
|
-
$parcel$export($
|
|
83
|
-
$parcel$export($
|
|
84
|
-
$parcel$export($
|
|
85
|
-
$parcel$export($
|
|
86
|
-
$parcel$export($
|
|
87
|
-
$parcel$export($
|
|
88
|
-
$parcel$export($
|
|
89
|
-
$parcel$export($
|
|
90
|
-
$parcel$export($
|
|
91
|
-
$parcel$export($
|
|
92
|
-
$parcel$export($
|
|
93
|
-
$parcel$export($
|
|
94
|
-
$parcel$export($
|
|
95
|
-
$parcel$export($
|
|
96
|
-
$parcel$export($
|
|
97
|
-
$parcel$export($
|
|
77
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "insertLineBreaksAfterPunctuation", () => $f4495ebb65d3b1e0$export$814bebc253f2e5df);
|
|
78
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "addSpaceBeforeAndAfterPunctuation", () => $f4495ebb65d3b1e0$export$f0306841cd6b95d5);
|
|
79
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "applySmartQuotes", () => $f4495ebb65d3b1e0$export$42f47e081bfe828c);
|
|
80
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "cleanLiteralNewLines", () => $f4495ebb65d3b1e0$export$b4922cc8c111eae2);
|
|
81
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "cleanMultilines", () => $f4495ebb65d3b1e0$export$95680a0d9bdd5dba);
|
|
82
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "hasWordInSingleLine", () => $f4495ebb65d3b1e0$export$20a121a9317a6ed4);
|
|
83
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "isOnlyPunctuation", () => $f4495ebb65d3b1e0$export$d936e191dd6a8e06);
|
|
84
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "cleanJunkFromText", () => $f4495ebb65d3b1e0$export$38e1db3c2502e6cc);
|
|
85
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "cleanSpacesBeforePeriod", () => $f4495ebb65d3b1e0$export$e65ff0050dc4971d);
|
|
86
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "condenseAsterisks", () => $f4495ebb65d3b1e0$export$6e89dcbda2f1dcad);
|
|
87
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "condenseColons", () => $f4495ebb65d3b1e0$export$64ee6721b5d4cefa);
|
|
88
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "condenseDashes", () => $f4495ebb65d3b1e0$export$9f873c000de6f69a);
|
|
89
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "condenseEllipsis", () => $f4495ebb65d3b1e0$export$35abf980a52dfe44);
|
|
90
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "reduceMultilineBreaksToDouble", () => $f4495ebb65d3b1e0$export$660f127778d3db20);
|
|
91
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "reduceMultilineBreaksToSingle", () => $f4495ebb65d3b1e0$export$7b984b558843c423);
|
|
92
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "condensePeriods", () => $f4495ebb65d3b1e0$export$3468167fbf4483d7);
|
|
93
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "condenseUnderscores", () => $f4495ebb65d3b1e0$export$a299139a27d861bb);
|
|
94
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "doubleToSingleBrackets", () => $f4495ebb65d3b1e0$export$55102718dfa8db7e);
|
|
95
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "formatStringBySentence", () => $f4495ebb65d3b1e0$export$748703bb362bd52c);
|
|
96
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "normalizeSlashInReferences", () => $f4495ebb65d3b1e0$export$9027754b4b9f4cf4);
|
|
97
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "normalizeSpaces", () => $f4495ebb65d3b1e0$export$85f748ccc2d3e888);
|
|
98
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "removeSpaceInsideBrackets", () => $f4495ebb65d3b1e0$export$6726e05a22c5d4c9);
|
|
99
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "stripBoldStyling", () => $f4495ebb65d3b1e0$export$6db2c5d62fd5ffe9);
|
|
100
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "stripItalicsStyling", () => $f4495ebb65d3b1e0$export$9340b5fbcad6fe5a);
|
|
101
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "stripStyling", () => $f4495ebb65d3b1e0$export$e166e222302a97bd);
|
|
102
|
+
$parcel$export($f4495ebb65d3b1e0$exports, "trimSpaceInsideQuotes", () => $f4495ebb65d3b1e0$export$eedf7f8c32995e56);
|
|
98
103
|
/**
|
|
99
104
|
* Adds line breaks after punctuation marks such as periods, exclamation points, and question marks.
|
|
100
105
|
* Example: 'Text.' becomes 'Text.\n'.
|
|
101
106
|
* @param {string} text - The input text containing punctuation.
|
|
102
107
|
* @returns {string} - The modified text with line breaks added after punctuation.
|
|
103
|
-
*/ const $
|
|
108
|
+
*/ const $f4495ebb65d3b1e0$export$814bebc253f2e5df = (text)=>{
|
|
104
109
|
// Define the punctuation marks that should trigger a new line
|
|
105
110
|
const punctuation = /([.?!؟])/g;
|
|
106
111
|
// Replace occurrences of punctuation marks followed by a space with the punctuation mark, a newline, and the space
|
|
107
|
-
const formattedText = text.replace(punctuation,
|
|
112
|
+
const formattedText = text.replace(punctuation, '$1\n').replace(/\n\s+/g, '\n').trim();
|
|
108
113
|
return formattedText;
|
|
109
114
|
};
|
|
110
|
-
const $
|
|
111
|
-
return text.replace(/( ?)([.!?,،؟;؛])((?![ '”“\)"\]\n])|(?=\s{2,}))/g,
|
|
115
|
+
const $f4495ebb65d3b1e0$export$f0306841cd6b95d5 = (text)=>{
|
|
116
|
+
return text.replace(/( ?)([.!?,،؟;؛])((?![ '”“\)"\]\n])|(?=\s{2,}))/g, '$1$2 ').replace(/\s([.!?,،؟;؛])\s*([ '”“\)"\]\n])/g, '$1$2').replace(/([^\s\w\d'”“\)"\]]+)\s+([.!?,،؟;؛])|([.!?,،؟;؛])\s+$/g, '$1$2$3').replace(/(?<=\D)( ?: ?)(?!(\d+:)|(:\d+))|(?<=\d) ?: ?(?=\D)|(?<=\D) ?: ?(?=\d)/g, ': ');
|
|
112
117
|
};
|
|
113
|
-
const $
|
|
118
|
+
const $f4495ebb65d3b1e0$export$42f47e081bfe828c = (text)=>{
|
|
114
119
|
return text.replace(/[“”]/g, '"').replace(/"([^"]*)"/g, "\u201C$1\u201D").replace(/^”/g, "\u201C");
|
|
115
120
|
};
|
|
116
|
-
const $
|
|
117
|
-
return text.replace(/\\n|\r/g,
|
|
121
|
+
const $f4495ebb65d3b1e0$export$b4922cc8c111eae2 = (text)=>{
|
|
122
|
+
return text.replace(/\\n|\r/g, '\n');
|
|
123
|
+
};
|
|
124
|
+
const $f4495ebb65d3b1e0$export$95680a0d9bdd5dba = (text)=>{
|
|
125
|
+
return text.replace(/^ +| +$/gm, '');
|
|
118
126
|
};
|
|
119
|
-
const $
|
|
120
|
-
return
|
|
127
|
+
const $f4495ebb65d3b1e0$export$20a121a9317a6ed4 = (text)=>{
|
|
128
|
+
return /^\s*\S+\s*$/gm.test(text);
|
|
121
129
|
};
|
|
122
|
-
const $
|
|
130
|
+
const $f4495ebb65d3b1e0$export$d936e191dd6a8e06 = (text)=>{
|
|
123
131
|
const regex = /^[\u0020-\u002f\u003a-\u0040\u005b-\u0060\u007b-\u007e0-9٠-٩]+$/;
|
|
124
132
|
return regex.test(text);
|
|
125
133
|
};
|
|
126
|
-
const $
|
|
127
|
-
const newBody = $
|
|
128
|
-
const lines = newBody.split(
|
|
129
|
-
return !line || line.length > 1 && !$
|
|
134
|
+
const $f4495ebb65d3b1e0$export$38e1db3c2502e6cc = (text)=>{
|
|
135
|
+
const newBody = $f4495ebb65d3b1e0$export$95680a0d9bdd5dba(text);
|
|
136
|
+
const lines = newBody.split('\n').filter((line)=>{
|
|
137
|
+
return !line || line.length > 1 && !$f4495ebb65d3b1e0$export$d936e191dd6a8e06(line);
|
|
130
138
|
});
|
|
131
|
-
return lines.join(
|
|
139
|
+
return lines.join('\n').trim();
|
|
132
140
|
};
|
|
133
|
-
const $
|
|
134
|
-
return text.replace(/\s+([.؟!,،؛:?])/g,
|
|
141
|
+
const $f4495ebb65d3b1e0$export$e65ff0050dc4971d = (text)=>{
|
|
142
|
+
return text.replace(/\s+([.؟!,،؛:?])/g, '$1');
|
|
135
143
|
};
|
|
136
|
-
const $
|
|
137
|
-
return text.replace(/(\*\s*)+/g,
|
|
144
|
+
const $f4495ebb65d3b1e0$export$6e89dcbda2f1dcad = (text)=>{
|
|
145
|
+
return text.replace(/(\*\s*)+/g, '*');
|
|
138
146
|
};
|
|
139
|
-
const $
|
|
140
|
-
return text.replace(/[\.-]?:[\.-]?/g,
|
|
147
|
+
const $f4495ebb65d3b1e0$export$64ee6721b5d4cefa = (text)=>{
|
|
148
|
+
return text.replace(/[\.-]?:[\.-]?/g, ':');
|
|
141
149
|
};
|
|
142
|
-
const $
|
|
143
|
-
return text.replace(/-{2,}/g,
|
|
150
|
+
const $f4495ebb65d3b1e0$export$9f873c000de6f69a = (text)=>{
|
|
151
|
+
return text.replace(/-{2,}/g, '-');
|
|
144
152
|
};
|
|
145
|
-
const $
|
|
153
|
+
const $f4495ebb65d3b1e0$export$35abf980a52dfe44 = (text)=>{
|
|
146
154
|
return text.replace(/\.{2,}/g, "\u2026");
|
|
147
155
|
};
|
|
148
|
-
const $
|
|
149
|
-
return text.replace(/(\n\s*){3,}/g,
|
|
156
|
+
const $f4495ebb65d3b1e0$export$660f127778d3db20 = (text)=>{
|
|
157
|
+
return text.replace(/(\n\s*){3,}/g, '\n\n');
|
|
150
158
|
};
|
|
151
|
-
const $
|
|
152
|
-
return text.replace(/(\n\s*){2,}/g,
|
|
159
|
+
const $f4495ebb65d3b1e0$export$7b984b558843c423 = (text)=>{
|
|
160
|
+
return text.replace(/(\n\s*){2,}/g, '\n');
|
|
153
161
|
};
|
|
154
|
-
const $
|
|
155
|
-
return text.replace(/\. +\./g,
|
|
162
|
+
const $f4495ebb65d3b1e0$export$3468167fbf4483d7 = (text)=>{
|
|
163
|
+
return text.replace(/\. +\./g, '.');
|
|
156
164
|
};
|
|
157
|
-
const $
|
|
158
|
-
return text.replace(/ـ{2,}/g, "\u0640").replace(/_+/g,
|
|
165
|
+
const $f4495ebb65d3b1e0$export$a299139a27d861bb = (text)=>{
|
|
166
|
+
return text.replace(/ـ{2,}/g, "\u0640").replace(/_+/g, '_');
|
|
159
167
|
};
|
|
160
|
-
const $
|
|
161
|
-
return text.replace(/(\(|\)){2,}|(\[|\]){2,}/g,
|
|
168
|
+
const $f4495ebb65d3b1e0$export$55102718dfa8db7e = (text)=>{
|
|
169
|
+
return text.replace(/(\(|\)){2,}|(\[|\]){2,}/g, '$1$2');
|
|
162
170
|
};
|
|
163
|
-
const $
|
|
171
|
+
const $f4495ebb65d3b1e0$export$748703bb362bd52c = (input)=>{
|
|
164
172
|
const footnoteRegex = /^\((?:\d+|۱|۲|۳|۴|۵|۶|۷|۸|۹)\)\s/;
|
|
165
173
|
const sentences = [];
|
|
166
|
-
const lines = input.split(
|
|
167
|
-
let currentSentence =
|
|
174
|
+
const lines = input.split('\n');
|
|
175
|
+
let currentSentence = '';
|
|
168
176
|
lines.forEach((line)=>{
|
|
169
177
|
const trimmedLine = line.trim();
|
|
170
178
|
const isFootnote = footnoteRegex.test(trimmedLine);
|
|
@@ -172,7 +180,7 @@ const $eee5f9a99eee384c$export$748703bb362bd52c = (input)=>{
|
|
|
172
180
|
if (isFootnote && !isNumber) {
|
|
173
181
|
if (currentSentence) {
|
|
174
182
|
sentences.push(currentSentence.trim());
|
|
175
|
-
currentSentence =
|
|
183
|
+
currentSentence = '';
|
|
176
184
|
}
|
|
177
185
|
sentences.push(trimmedLine);
|
|
178
186
|
} else {
|
|
@@ -180,106 +188,106 @@ const $eee5f9a99eee384c$export$748703bb362bd52c = (input)=>{
|
|
|
180
188
|
const lastChar = currentSentence.trim().slice(-1);
|
|
181
189
|
if (/[.!؟]/.test(lastChar)) {
|
|
182
190
|
sentences.push(currentSentence.trim());
|
|
183
|
-
currentSentence =
|
|
191
|
+
currentSentence = '';
|
|
184
192
|
}
|
|
185
193
|
}
|
|
186
194
|
});
|
|
187
195
|
// Add any remaining text to the output
|
|
188
196
|
if (currentSentence) sentences.push(currentSentence.trim());
|
|
189
|
-
return sentences.join(
|
|
197
|
+
return sentences.join('\n');
|
|
190
198
|
};
|
|
191
|
-
const $
|
|
192
|
-
return text.replace(/(\d+)\s?\/\s?(\d+)/g,
|
|
199
|
+
const $f4495ebb65d3b1e0$export$9027754b4b9f4cf4 = (text)=>{
|
|
200
|
+
return text.replace(/(\d+)\s?\/\s?(\d+)/g, '$1/$2');
|
|
193
201
|
};
|
|
194
|
-
const $
|
|
195
|
-
return text.replace(/[ \t]+/g,
|
|
202
|
+
const $f4495ebb65d3b1e0$export$85f748ccc2d3e888 = (text)=>{
|
|
203
|
+
return text.replace(/[ \t]+/g, ' ');
|
|
196
204
|
};
|
|
197
|
-
const $
|
|
198
|
-
return text.replace(/([\[\(])\s*(.*?)\s*([\]\)])/g,
|
|
205
|
+
const $f4495ebb65d3b1e0$export$6726e05a22c5d4c9 = (text)=>{
|
|
206
|
+
return text.replace(/([\[\(])\s*(.*?)\s*([\]\)])/g, '$1$2$3');
|
|
199
207
|
};
|
|
200
|
-
const $
|
|
208
|
+
const $f4495ebb65d3b1e0$export$6db2c5d62fd5ffe9 = (text)=>{
|
|
201
209
|
// Normalize the string to NFKD form
|
|
202
|
-
const normalizedString = text.normalize(
|
|
210
|
+
const normalizedString = text.normalize('NFKD');
|
|
203
211
|
// Remove combining marks (diacritics) and stylistic characters from the string
|
|
204
|
-
return normalizedString.replace(/[\u0300-\u036f]/g,
|
|
212
|
+
return normalizedString.replace(/[\u0300-\u036f]/g, '').trim();
|
|
205
213
|
};
|
|
206
|
-
const $
|
|
214
|
+
const $f4495ebb65d3b1e0$export$9340b5fbcad6fe5a = (text)=>{
|
|
207
215
|
const italicMap = {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
216
|
+
'\uD835\uDC4E': 'I',
|
|
217
|
+
'\uD835\uDC68': 'g',
|
|
218
|
+
'\u{1D63C}': '!',
|
|
219
|
+
'\uD835\uDC4F': 'J',
|
|
220
|
+
'\uD835\uDC69': 'h',
|
|
221
|
+
'\u{1D63D}': '?',
|
|
222
|
+
'\uD835\uDC50': 'K',
|
|
223
|
+
'\uD835\uDC6A': 'i',
|
|
224
|
+
'\uD835\uDC51': 'L',
|
|
225
|
+
'\uD835\uDC6B': 'j',
|
|
226
|
+
'\u{1D63F}': ',',
|
|
227
|
+
'\uD835\uDC52': 'M',
|
|
228
|
+
'\uD835\uDC6C': 'k',
|
|
229
|
+
'\u{1D640}': '.',
|
|
230
|
+
'\uD835\uDC53': 'N',
|
|
231
|
+
'\uD835\uDC6D': 'l',
|
|
232
|
+
'\uD835\uDC54': 'O',
|
|
233
|
+
'\uD835\uDC6E': 'm',
|
|
234
|
+
'\uD835\uDC6F': 'n',
|
|
235
|
+
'\uD835\uDC56': 'Q',
|
|
236
|
+
'\uD835\uDC70': 'o',
|
|
237
|
+
'\uD835\uDC57': 'R',
|
|
238
|
+
'\uD835\uDC71': 'p',
|
|
239
|
+
'\uD835\uDC58': 'S',
|
|
240
|
+
'\uD835\uDC72': 'q',
|
|
241
|
+
'\uD835\uDC59': 'T',
|
|
242
|
+
'\uD835\uDC73': 'r',
|
|
243
|
+
'\u{1D647}': '-',
|
|
244
|
+
'\uD835\uDC5A': 'U',
|
|
245
|
+
'\uD835\uDC74': 's',
|
|
246
|
+
'\uD835\uDC5B': 'V',
|
|
247
|
+
'\uD835\uDC75': 't',
|
|
248
|
+
'\uD835\uDC5C': 'W',
|
|
249
|
+
'\uD835\uDC76': 'u',
|
|
250
|
+
'\uD835\uDC5D': 'X',
|
|
251
|
+
'\uD835\uDC77': 'v',
|
|
252
|
+
'\uD835\uDC5E': 'Y',
|
|
253
|
+
'\uD835\uDC78': 'w',
|
|
254
|
+
'\uD835\uDC5F': 'Z',
|
|
255
|
+
'\uD835\uDC79': 'x',
|
|
256
|
+
'\uD835\uDC46': 'A',
|
|
257
|
+
'\uD835\uDC7A': 'y',
|
|
258
|
+
'\uD835\uDC47': 'B',
|
|
259
|
+
'\uD835\uDC7B': 'z',
|
|
260
|
+
'\uD835\uDC62': 'a',
|
|
261
|
+
'\uD835\uDC48': 'C',
|
|
262
|
+
'\uD835\uDC63': 'b',
|
|
263
|
+
'\uD835\uDC49': 'D',
|
|
264
|
+
'\uD835\uDC64': 'c',
|
|
265
|
+
'\uD835\uDC4A': 'E',
|
|
266
|
+
'\uD835\uDC65': 'd',
|
|
267
|
+
'\uD835\uDC4B': 'F',
|
|
268
|
+
'\uD835\uDC66': 'e',
|
|
269
|
+
'\uD835\uDC4C': 'G',
|
|
270
|
+
'\uD835\uDC67': 'f',
|
|
271
|
+
'\uD835\uDC4D': 'H',
|
|
272
|
+
'\uD835\uDC55': 'P'
|
|
265
273
|
};
|
|
266
274
|
return text.replace(/[\uD835\uDC62-\uD835\uDC7B\uD835\uDC46-\uD835\uDC5F\u{1D63C}-\u{1D647}]/gu, (match)=>{
|
|
267
275
|
return italicMap[match] || match;
|
|
268
276
|
});
|
|
269
277
|
};
|
|
270
|
-
const $
|
|
271
|
-
return $
|
|
278
|
+
const $f4495ebb65d3b1e0$export$e166e222302a97bd = (text)=>{
|
|
279
|
+
return $f4495ebb65d3b1e0$export$9340b5fbcad6fe5a($f4495ebb65d3b1e0$export$6db2c5d62fd5ffe9(text));
|
|
272
280
|
};
|
|
273
|
-
const $
|
|
274
|
-
return text.replace(/([“”"]|«) *(.*?) *([“”"]|»)/g,
|
|
281
|
+
const $f4495ebb65d3b1e0$export$eedf7f8c32995e56 = (text)=>{
|
|
282
|
+
return text.replace(/([“”"]|«) *(.*?) *([“”"]|»)/g, '$1$2$3');
|
|
275
283
|
};
|
|
276
284
|
|
|
277
285
|
|
|
278
|
-
var $
|
|
286
|
+
var $0a00bc254018888e$exports = {};
|
|
279
287
|
|
|
280
|
-
$parcel$export($
|
|
281
|
-
$parcel$export($
|
|
282
|
-
$parcel$export($
|
|
288
|
+
$parcel$export($0a00bc254018888e$exports, "normalizeJsonSyntax", () => $0a00bc254018888e$export$62c7e2fbc3880e40);
|
|
289
|
+
$parcel$export($0a00bc254018888e$exports, "isJsonStructureValid", () => $0a00bc254018888e$export$70726570eaa51acb);
|
|
290
|
+
$parcel$export($0a00bc254018888e$exports, "splitByQuotes", () => $0a00bc254018888e$export$ae2dc619900afbaa);
|
|
283
291
|
/**
|
|
284
292
|
* Converts a string that resembles JSON but with numeric keys and single-quoted values
|
|
285
293
|
* into valid JSON format. This function replaces numeric keys with quoted numeric keys
|
|
@@ -291,103 +299,103 @@ $parcel$export($f7ff16ea5ce4e27b$exports, "splitByQuotes", () => $f7ff16ea5ce4e2
|
|
|
291
299
|
* @example
|
|
292
300
|
* const result = normalizeJsonSyntax("{10: 'abc', 20: 'def'}");
|
|
293
301
|
* console.log(result); // '{"10": "abc", "20": "def"}'
|
|
294
|
-
*/ const $
|
|
302
|
+
*/ const $0a00bc254018888e$export$62c7e2fbc3880e40 = (str)=>{
|
|
295
303
|
let input = str.replace(/(\b\d+\b)(?=:)/g, '"$1"');
|
|
296
304
|
input = input.replace(/:\s*'([^']+)'/g, ': "$1"');
|
|
297
305
|
input = input.replace(/:\s*"([^"]+)"/g, ': "$1"');
|
|
298
306
|
return JSON.stringify(JSON.parse(input));
|
|
299
307
|
};
|
|
300
|
-
const $
|
|
308
|
+
const $0a00bc254018888e$export$70726570eaa51acb = (str)=>{
|
|
301
309
|
// Checks for a pattern with numeric keys or quoted keys and values in quotes
|
|
302
310
|
const jsonLikePattern = /^{(\s*(\d+|'[^']*'|"[^"]*")\s*:\s*('|")[^'"]*\3\s*,)*(?:\s*(\d+|'[^']*'|"[^"]*")\s*:\s*('|")[^'"]*\5\s*)}$/;
|
|
303
311
|
return jsonLikePattern.test(str.trim());
|
|
304
312
|
};
|
|
305
|
-
const $
|
|
313
|
+
const $0a00bc254018888e$export$ae2dc619900afbaa = (query)=>{
|
|
306
314
|
const regex = /(?:[^\s"]+|"(.*?)")+/g;
|
|
307
315
|
return (query.match(regex) || []).map((s)=>s.startsWith('"') ? s.slice(1, -1) : s);
|
|
308
316
|
};
|
|
309
317
|
|
|
310
318
|
|
|
311
|
-
var $
|
|
319
|
+
var $1f25f0941eacce7f$exports = {};
|
|
312
320
|
|
|
313
|
-
$parcel$export($
|
|
314
|
-
$parcel$export($
|
|
315
|
-
$parcel$export($
|
|
316
|
-
$parcel$export($
|
|
317
|
-
$parcel$export($
|
|
318
|
-
$parcel$export($
|
|
319
|
-
$parcel$export($
|
|
320
|
-
$parcel$export($
|
|
321
|
+
$parcel$export($1f25f0941eacce7f$exports, "cleanSymbolsAndPartReferences", () => $1f25f0941eacce7f$export$70476c4e7ef0b147);
|
|
322
|
+
$parcel$export($1f25f0941eacce7f$exports, "cleanTrailingPageNumbers", () => $1f25f0941eacce7f$export$9f81734a6223638b);
|
|
323
|
+
$parcel$export($1f25f0941eacce7f$exports, "replaceLineBreaksWithSpaces", () => $1f25f0941eacce7f$export$631d05f860fc7118);
|
|
324
|
+
$parcel$export($1f25f0941eacce7f$exports, "stripAllDigits", () => $1f25f0941eacce7f$export$edd6c3bb8fa3bc01);
|
|
325
|
+
$parcel$export($1f25f0941eacce7f$exports, "removeDeathYear", () => $1f25f0941eacce7f$export$a537ffbd78859923);
|
|
326
|
+
$parcel$export($1f25f0941eacce7f$exports, "removeNumbersAndDashes", () => $1f25f0941eacce7f$export$c8e7d4d7d9f46256);
|
|
327
|
+
$parcel$export($1f25f0941eacce7f$exports, "removeSingleDigitReferences", () => $1f25f0941eacce7f$export$8e7f001aa315ad82);
|
|
328
|
+
$parcel$export($1f25f0941eacce7f$exports, "removeUrls", () => $1f25f0941eacce7f$export$e4a0bb7881a4591a);
|
|
321
329
|
/**
|
|
322
330
|
* Removes various symbols, part references, and numerical markers from the text.
|
|
323
331
|
* Example: '(1) (2/3)' becomes ''.
|
|
324
332
|
* @param {string} text - The input text to apply the rule to.
|
|
325
333
|
* @returns {string} - The modified text with symbols and part references removed.
|
|
326
|
-
*/ const $
|
|
327
|
-
return text.replace(/ *\(?:\d+(?:\/\d+){0,2}\)? *| *\[\d+(?:\/\d+)?\] *| *«\d+» *|\d+\/\d+(?:\/\d+)?|[،§{}؍﴿﴾<>;_؟»«:!،؛\[\]…ـ¬\.\\\/\*\(\)"]/g,
|
|
334
|
+
*/ const $1f25f0941eacce7f$export$70476c4e7ef0b147 = (text)=>{
|
|
335
|
+
return text.replace(/ *\(?:\d+(?:\/\d+){0,2}\)? *| *\[\d+(?:\/\d+)?\] *| *«\d+» *|\d+\/\d+(?:\/\d+)?|[،§{}؍﴿﴾<>;_؟»«:!،؛\[\]…ـ¬\.\\\/\*\(\)"]/g, ' ');
|
|
328
336
|
};
|
|
329
|
-
const $
|
|
330
|
-
return text.replace(/-\[\d+\]-/g,
|
|
337
|
+
const $1f25f0941eacce7f$export$9f81734a6223638b = (text)=>{
|
|
338
|
+
return text.replace(/-\[\d+\]-/g, '');
|
|
331
339
|
};
|
|
332
|
-
const $
|
|
333
|
-
return text.replace(/\s+/g,
|
|
340
|
+
const $1f25f0941eacce7f$export$631d05f860fc7118 = (text)=>{
|
|
341
|
+
return text.replace(/\s+/g, ' ');
|
|
334
342
|
};
|
|
335
|
-
const $
|
|
336
|
-
return text.replace(/[0-9]/g,
|
|
343
|
+
const $1f25f0941eacce7f$export$edd6c3bb8fa3bc01 = (text)=>{
|
|
344
|
+
return text.replace(/[0-9]/g, '');
|
|
337
345
|
};
|
|
338
|
-
const $
|
|
339
|
-
return text.replace(/\[(d)\.\s*\d{1,4}[hH]\]\s*|\((d)\.\s*\d{1,4}[hH]\)\s*/g,
|
|
346
|
+
const $1f25f0941eacce7f$export$a537ffbd78859923 = (text)=>{
|
|
347
|
+
return text.replace(/\[(d)\.\s*\d{1,4}[hH]\]\s*|\((d)\.\s*\d{1,4}[hH]\)\s*/g, '');
|
|
340
348
|
};
|
|
341
|
-
const $
|
|
342
|
-
return text.replace(/[\d-]/g,
|
|
349
|
+
const $1f25f0941eacce7f$export$c8e7d4d7d9f46256 = (text)=>{
|
|
350
|
+
return text.replace(/[\d-]/g, '');
|
|
343
351
|
};
|
|
344
|
-
const $
|
|
345
|
-
return text.replace(/\(\d{1}\)|\[\d{1}\]|«\d»/g,
|
|
352
|
+
const $1f25f0941eacce7f$export$8e7f001aa315ad82 = (text)=>{
|
|
353
|
+
return text.replace(/\(\d{1}\)|\[\d{1}\]|«\d»/g, '');
|
|
346
354
|
};
|
|
347
|
-
const $
|
|
348
|
-
return text.replace(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g,
|
|
355
|
+
const $1f25f0941eacce7f$export$e4a0bb7881a4591a = (text)=>{
|
|
356
|
+
return text.replace(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g, '');
|
|
349
357
|
};
|
|
350
358
|
|
|
351
359
|
|
|
352
|
-
var $
|
|
360
|
+
var $2d6eb7113bd26878$exports = {};
|
|
353
361
|
|
|
354
|
-
$parcel$export($
|
|
355
|
-
$parcel$export($
|
|
356
|
-
$parcel$export($
|
|
357
|
-
$parcel$export($
|
|
358
|
-
$parcel$export($
|
|
359
|
-
$parcel$export($
|
|
360
|
-
$parcel$export($
|
|
361
|
-
$parcel$export($
|
|
362
|
+
$parcel$export($2d6eb7113bd26878$exports, "normalizeArabicPrefixesToAl", () => $2d6eb7113bd26878$export$2a02c946f8bfe63e);
|
|
363
|
+
$parcel$export($2d6eb7113bd26878$exports, "normalizeDoubleApostrophes", () => $2d6eb7113bd26878$export$bdee7fc4cb327c1a);
|
|
364
|
+
$parcel$export($2d6eb7113bd26878$exports, "replaceSalutationsWithSymbol", () => $2d6eb7113bd26878$export$a0f0be7fbc73baaa);
|
|
365
|
+
$parcel$export($2d6eb7113bd26878$exports, "normalize", () => $2d6eb7113bd26878$export$a3295358bff77e);
|
|
366
|
+
$parcel$export($2d6eb7113bd26878$exports, "normalizeApostrophes", () => $2d6eb7113bd26878$export$a4e89c859f54cbf3);
|
|
367
|
+
$parcel$export($2d6eb7113bd26878$exports, "removeArabicPrefixes", () => $2d6eb7113bd26878$export$dcfbf7d1ecba5f64);
|
|
368
|
+
$parcel$export($2d6eb7113bd26878$exports, "normalizeTransliteratedEnglish", () => $2d6eb7113bd26878$export$17df925670d0176a);
|
|
369
|
+
$parcel$export($2d6eb7113bd26878$exports, "extractInitials", () => $2d6eb7113bd26878$export$d421e6fd95c29a67);
|
|
362
370
|
|
|
363
|
-
const $
|
|
364
|
-
return text.replace(/(\b|\W)(Al |Al-|Ar-|As-|Adh-|Ad-|Ats-|Ath |Ath-|Az |Az-|az-|adh-|as-|ar-)/g,
|
|
371
|
+
const $2d6eb7113bd26878$export$2a02c946f8bfe63e = (text)=>{
|
|
372
|
+
return text.replace(/(\b|\W)(Al |Al-|Ar-|As-|Adh-|Ad-|Ats-|Ath |Ath-|Az |Az-|az-|adh-|as-|ar-)/g, '$1al-').replace(/(\b|\W)(Ash-S|ash-S)/g, '$1al-S').replace(/al- (.+?)\b/g, 'al-$1');
|
|
365
373
|
};
|
|
366
|
-
const $
|
|
374
|
+
const $2d6eb7113bd26878$export$bdee7fc4cb327c1a = (text)=>{
|
|
367
375
|
return text.replace(/ʿʿ/g, "\u02BF").replace(/ʾʾ/g, "\u02BE");
|
|
368
376
|
};
|
|
369
|
-
const $
|
|
377
|
+
const $2d6eb7113bd26878$export$a0f0be7fbc73baaa = (text)=>{
|
|
370
378
|
return text.replace(/\(peace be upon him\)|(Messenger of (Allah|Allāh)|Messenger|Prophet|Mu[hḥ]ammad) *\((s[^)]*m|peace[^)]*him|May[^)]*him|may[^)]*him)\)*/gi, "$1 \uFDFA").replace(/,\s*ﷺ\s*,/g, " \uFDFA");
|
|
371
379
|
};
|
|
372
|
-
const $
|
|
373
|
-
return input.normalize(
|
|
380
|
+
const $2d6eb7113bd26878$export$a3295358bff77e = (input)=>{
|
|
381
|
+
return input.normalize('NFKD').replace(/[\u0300-\u036f]/g, '').replace(/`|ʾ|ʿ|-/g, '');
|
|
374
382
|
};
|
|
375
|
-
const $
|
|
383
|
+
const $2d6eb7113bd26878$export$a4e89c859f54cbf3 = (text)=>{
|
|
376
384
|
return text.replace(/‛|’|‘/g, "'");
|
|
377
385
|
};
|
|
378
|
-
const $
|
|
379
|
-
return (0, $
|
|
386
|
+
const $2d6eb7113bd26878$export$dcfbf7d1ecba5f64 = (text)=>{
|
|
387
|
+
return (0, $f4495ebb65d3b1e0$export$85f748ccc2d3e888)(text.replace(/(\bal-|\bli-|\bbi-|\bfī|\bwa[-\s]+|\bl-|\bliʿl|\Bʿalá|\Bʿan|\bb\.)/gi, ''));
|
|
380
388
|
};
|
|
381
|
-
const $
|
|
382
|
-
const $
|
|
383
|
-
const initials = $
|
|
389
|
+
const $2d6eb7113bd26878$export$17df925670d0176a = (text)=>$2d6eb7113bd26878$export$a3295358bff77e($2d6eb7113bd26878$export$dcfbf7d1ecba5f64(text));
|
|
390
|
+
const $2d6eb7113bd26878$export$d421e6fd95c29a67 = (fullName)=>{
|
|
391
|
+
const initials = $2d6eb7113bd26878$export$17df925670d0176a(fullName).trim().split(/[ -]/).slice(0, 2).map((word)=>{
|
|
384
392
|
return word.charAt(0).toUpperCase();
|
|
385
|
-
}).join(
|
|
393
|
+
}).join('');
|
|
386
394
|
return initials;
|
|
387
395
|
};
|
|
388
396
|
|
|
389
397
|
|
|
390
398
|
|
|
391
399
|
|
|
392
|
-
export {$
|
|
400
|
+
export {$28624456cd7e4cb8$export$60dc7fb96c441688 as cleanExtremeArabicUnderscores, $28624456cd7e4cb8$export$dcf00cfaf31fd188 as convertUrduSymbolsToArabic, $28624456cd7e4cb8$export$6c58e29008d10c1d as fixTrailingWow, $28624456cd7e4cb8$export$cf81487e80b00e26 as addSpaceBetweenArabicTextAndNumbers, $28624456cd7e4cb8$export$df81ab2e9352ca65 as stripEnglishCharactersAndSymbols, $28624456cd7e4cb8$export$d580a3cb14401529 as removeNonIndexSignatures, $28624456cd7e4cb8$export$84d849da647fa2e5 as removeSingularCodes, $28624456cd7e4cb8$export$7dedbc726019ed0f as removeSolitaryArabicLetters, $28624456cd7e4cb8$export$9571c9c2c203652d as removeTatwil, $28624456cd7e4cb8$export$f95230335378ec58 as replaceTaMarbutahWithHa, $28624456cd7e4cb8$export$b5bee4b27048330b as stripDiacritics, $28624456cd7e4cb8$export$8696bb09194c5fb5 as stripZeroWidthCharacters, $28624456cd7e4cb8$export$b1d6cb321dee12ad as replaceAlifMaqsurah, $28624456cd7e4cb8$export$db0c96cd03237332 as replaceEnglishPunctuationWithArabic, $28624456cd7e4cb8$export$1d28b07894af8a98 as normalizeAlifVariants, $f4495ebb65d3b1e0$export$814bebc253f2e5df as insertLineBreaksAfterPunctuation, $f4495ebb65d3b1e0$export$f0306841cd6b95d5 as addSpaceBeforeAndAfterPunctuation, $f4495ebb65d3b1e0$export$42f47e081bfe828c as applySmartQuotes, $f4495ebb65d3b1e0$export$b4922cc8c111eae2 as cleanLiteralNewLines, $f4495ebb65d3b1e0$export$95680a0d9bdd5dba as cleanMultilines, $f4495ebb65d3b1e0$export$20a121a9317a6ed4 as hasWordInSingleLine, $f4495ebb65d3b1e0$export$d936e191dd6a8e06 as isOnlyPunctuation, $f4495ebb65d3b1e0$export$38e1db3c2502e6cc as cleanJunkFromText, $f4495ebb65d3b1e0$export$e65ff0050dc4971d as cleanSpacesBeforePeriod, $f4495ebb65d3b1e0$export$6e89dcbda2f1dcad as condenseAsterisks, $f4495ebb65d3b1e0$export$64ee6721b5d4cefa as condenseColons, $f4495ebb65d3b1e0$export$9f873c000de6f69a as condenseDashes, $f4495ebb65d3b1e0$export$35abf980a52dfe44 as condenseEllipsis, $f4495ebb65d3b1e0$export$660f127778d3db20 as reduceMultilineBreaksToDouble, $f4495ebb65d3b1e0$export$7b984b558843c423 as reduceMultilineBreaksToSingle, $f4495ebb65d3b1e0$export$3468167fbf4483d7 as condensePeriods, $f4495ebb65d3b1e0$export$a299139a27d861bb as condenseUnderscores, $f4495ebb65d3b1e0$export$55102718dfa8db7e as doubleToSingleBrackets, $f4495ebb65d3b1e0$export$748703bb362bd52c as formatStringBySentence, $f4495ebb65d3b1e0$export$9027754b4b9f4cf4 as normalizeSlashInReferences, $f4495ebb65d3b1e0$export$85f748ccc2d3e888 as normalizeSpaces, $f4495ebb65d3b1e0$export$6726e05a22c5d4c9 as removeSpaceInsideBrackets, $f4495ebb65d3b1e0$export$6db2c5d62fd5ffe9 as stripBoldStyling, $f4495ebb65d3b1e0$export$9340b5fbcad6fe5a as stripItalicsStyling, $f4495ebb65d3b1e0$export$e166e222302a97bd as stripStyling, $f4495ebb65d3b1e0$export$eedf7f8c32995e56 as trimSpaceInsideQuotes, $0a00bc254018888e$export$62c7e2fbc3880e40 as normalizeJsonSyntax, $0a00bc254018888e$export$70726570eaa51acb as isJsonStructureValid, $0a00bc254018888e$export$ae2dc619900afbaa as splitByQuotes, $1f25f0941eacce7f$export$70476c4e7ef0b147 as cleanSymbolsAndPartReferences, $1f25f0941eacce7f$export$9f81734a6223638b as cleanTrailingPageNumbers, $1f25f0941eacce7f$export$631d05f860fc7118 as replaceLineBreaksWithSpaces, $1f25f0941eacce7f$export$edd6c3bb8fa3bc01 as stripAllDigits, $1f25f0941eacce7f$export$a537ffbd78859923 as removeDeathYear, $1f25f0941eacce7f$export$c8e7d4d7d9f46256 as removeNumbersAndDashes, $1f25f0941eacce7f$export$8e7f001aa315ad82 as removeSingleDigitReferences, $1f25f0941eacce7f$export$e4a0bb7881a4591a as removeUrls, $2d6eb7113bd26878$export$2a02c946f8bfe63e as normalizeArabicPrefixesToAl, $2d6eb7113bd26878$export$bdee7fc4cb327c1a as normalizeDoubleApostrophes, $2d6eb7113bd26878$export$a0f0be7fbc73baaa as replaceSalutationsWithSymbol, $2d6eb7113bd26878$export$a3295358bff77e as normalize, $2d6eb7113bd26878$export$a4e89c859f54cbf3 as normalizeApostrophes, $2d6eb7113bd26878$export$dcfbf7d1ecba5f64 as removeArabicPrefixes, $2d6eb7113bd26878$export$17df925670d0176a as normalizeTransliteratedEnglish, $2d6eb7113bd26878$export$d421e6fd95c29a67 as extractInitials};
|
|
393
401
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;ACAA;;;;;;CAMC,GACM,MAAM,4CAAgC,CAAC;IAC1C,OAAO,KAAK,OAAO,CAAC,sCAAsC;AAC9D;AAQO,MAAM,4CAA6B,CAAC;IACvC,OAAO,KAAK,OAAO,CAAC,MAAM,UAAK,OAAO,CAAC,MAAM;AACjD;AASO,MAAM,4CAAiB,CAAC;IAC3B,OAAO,KAAK,OAAO,CAAC,QAAQ;AAChC;AAQO,MAAM,4CAAsC,CAAC;IAChD,OAAO,KAAK,OAAO,CAAC,4BAA4B;AACpD;AAQO,MAAM,4CAAmC,CAAC;IAC7C,OAAO,KAAK,OAAO,CAAC,yCAAyC;AACjE;AAQO,MAAM,4CAA2B,CAAC;IACrC,OAAO,KACF,OAAO,CAAC,kEAAkE,KAC1E,OAAO,CAAC,+DAA+D;AAChF;AAQO,MAAM,4CAAsB,CAAC;IAChC,OAAO,KAAK,OAAO,CAAC,+CAA+C;AACvE;AAQO,MAAM,4CAA8B,CAAC;IACxC,OAAO,KAAK,OAAO,CAAC,8BAA8B;AACtD;AAQO,MAAM,4CAA0B,CAAC;IACpC,OAAO,KAAK,OAAO,CAAC,QAAQ;AAChC;AAQO,MAAM,4CAAkB,CAAC;IAC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,MAAM,CAAC,GAAG,WAAW;IACrC,GACC,IAAI,CAAC;IACV,OAAO;AACX;","sources":["src/index.ts","src/arabic.ts","src/formatting.ts","src/parsing.ts","src/sanitization.ts","src/transliteration.ts"],"sourcesContent":["export * from './arabic';\nexport * from './formatting';\nexport * from './parsing';\nexport * from './sanitization';\nexport * from './transliteration';\n","/**\n * Removes extreme Arabic underscores (ـ) that appear at the beginning or end of a line or in text.\n * Does not affect Hijri dates (e.g., 1424هـ) or specific Arabic terms.\n * Example: \"ـThis is a textـ\" will be changed to \"This is a text\".\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with extreme underscores removed.\n */\nexport const cleanExtremeArabicUnderscores = (text: string): string => {\n return text.replace(/(?<!\\d ?ه|اه)ـ(?=\\r?$)|^ـ(?!اهـ)/gm, '');\n};\n\n/**\n * Converts Urdu symbols to their Arabic equivalents.\n * Example: 'ھذا' will be changed to 'هذا', 'ی' to 'ي'.\n * @param {string} text - The input text containing Urdu symbols.\n * @returns {string} - The modified text with Urdu symbols converted to Arabic symbols.\n */\nexport const convertUrduSymbolsToArabic = (text: string): string => {\n return text.replace(/ھ/g, 'ه').replace(/ی/g, 'ي');\n};\n\n/**\n * Fixes the trailing \"و\" (wow) in phrases such as \"عليكم و رحمة\" to \"عليكم ورحمة\".\n * This function attempts to correct phrases where \"و\" appears unnecessarily, particularly in greetings.\n * Example: 'السلام عليكم و رحمة' will be changed to 'السلام عليكم ورحمة'.\n * @param {string} text - The input text containing the \"و\" character.\n * @returns {string} - The modified text with unnecessary trailing \"و\" characters corrected.\n */\nexport const fixTrailingWow = (text: string): string => {\n return text.replace(/ و /g, ' و');\n};\n\n/**\n * Inserts a space between Arabic text and numbers.\n * Example: 'الآية37' will be changed to 'الآية 37'.\n * @param {string} text - The input text containing Arabic text followed by numbers.\n * @returns {string} - The modified text with spaces inserted between Arabic text and numbers.\n */\nexport const addSpaceBetweenArabicTextAndNumbers = (text: string): string => {\n return text.replace(/([\\u0600-\\u06FF]+)(\\d+)/g, '$1 $2');\n};\n\n/**\n * Removes English letters and symbols from the text, including ampersands, slashes, and other symbols.\n * Example: 'أحب & لنفسي' will be changed to 'أحب لنفسي'.\n * @param {string} text - The input text containing English letters and symbols.\n * @returns {string} - The modified text with English letters and symbols removed.\n */\nexport const stripEnglishCharactersAndSymbols = (text: string): string => {\n return text.replace(/[a-zA-Z]+[0-9]*|[¬§`ﷺ=]|\\/{2,}|&/g, ' ');\n};\n\n/**\n * Removes single-digit numbers surrounded by Arabic text. Also removes dashes (-) not followed by a number.\n * For example, removes '3' from 'وهب 3 وقال' but does not remove '121' from 'لوحه 121 الجرح'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with non-index numbers and dashes removed.\n */\nexport const removeNonIndexSignatures = (text: string): string => {\n return text\n .replace(/(?<![0-9] ?)-|(?<=[\\u0600-\\u06FF])\\s?\\d\\s?(?=[\\u0600-\\u06FF])/g, ' ')\n .replace(/(?<=[\\u0600-\\u06FF]\\s)(\\d+\\s)+\\d+(?=(\\s[\\u0600-\\u06FF]|$))/g, ' ');\n};\n\n/**\n * Removes characters enclosed in square brackets [] or parentheses () if they are Arabic letters or Arabic-Indic numerals.\n * Example: '[س]' or '(س)' will be removed.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with singular codes removed.\n */\nexport const removeSingularCodes = (text: string): string => {\n return text.replace(/[\\[\\({][\\u0621-\\u064A\\u0660-\\u0669][\\]\\)}]/g, '');\n};\n\n/**\n * Removes solitary Arabic letters unless they are the 'ha' letter, which is used in Hijri years.\n * Example: \"ب ا الكلمات ت\" will be changed to \"ا الكلمات\".\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with solitary Arabic letters removed.\n */\nexport const removeSolitaryArabicLetters = (text: string): string => {\n return text.replace(/(^| )[\\u0621-\\u064A]( |$)/g, ' ');\n};\n\n/**\n * Replaces the 'tah marbutah' (ة) character with 'ha' (ه).\n * Example: 'مدرسة' will be changed to 'مدرسه'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with 'ta marbutah' replaced by 'ha'.\n */\nexport const replaceTaMarbutahWithHa = (text: string): string => {\n return text.replace(/[ة]/g, 'ه');\n};\n\n/**\n * Removes Arabic diacritics (tashkeel) and the tatweel (elongation) character.\n * Example: 'مُحَمَّدٌ' will be changed to 'محمد'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with diacritics and tatweel removed.\n */\nexport const stripDiacritics = (text: string): string => {\n return text.replace(\n /[\\u0610\\u0611\\u0612\\u0613\\u0614\\u0615\\u0616\\u0617\\u0618\\u0619\\u061A\\u064B\\u064C\\u064D\\u064E\\u064F\\u0650\\u0651\\u0652\\u0653\\u0654\\u0655\\u0656\\u0657\\u0658\\u065A\\u065B\\u065C\\u065D\\u065E\\u0640]/g,\n '',\n );\n};\n\n/**\n * Removes zero-width joiners (ZWJ) and other zero-width characters from the input text.\n * Zero-width characters include U+200B to U+200F, U+202A to U+202E, U+2060 to U+2064, and U+FEFF.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with zero-width characters removed.\n */\nexport const stripZeroWidthCharacters = (text: string): string => {\n return text.replace(/[\\u200B-\\u200F\\u202A-\\u202E\\u2060-\\u2064\\uFEFF]/g, ' ');\n};\n\n/**\n * Replaces the 'alif maqsurah' (ى) character with the regular 'ya' (ي).\n * Example: 'رؤيى' will be changed to 'رؤيي'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with 'alif maqsurah' replaced by 'ya'.\n */\nexport const replaceAlifMaqsurah = (text: string): string => {\n return text.replace(/[ىي]/g, 'ي');\n};\n\n/**\n * Replaces English punctuation (question mark and semicolon) with their Arabic equivalents.\n * Example: '?' will be replaced with '؟', and ';' with '؛'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with English punctuation replaced by Arabic punctuation.\n */\nexport const replaceEnglishPunctuationWithArabic = (text: string): string => {\n return text\n .replace(/\\?|؟\\./g, '؟')\n .replace(/(;|؛)\\s*(\\1\\s*)*/g, '؛')\n .replace(/,|-،/g, '،');\n};\n\n/**\n * Simplifies all forms of 'alif' (أ, إ, and آ) to the basic 'ا'.\n * Example: 'أنا إلى الآفاق' will be changed to 'انا الى الافاق'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with simplified 'alif' characters.\n */\nexport const normalizeAlifVariants = (text: string): string => {\n return text.replace(/[أإآ]/g, 'ا');\n};\n","/**\n * Adds line breaks after punctuation marks such as periods, exclamation points, and question marks.\n * Example: 'Text.' becomes 'Text.\\n'.\n * @param {string} text - The input text containing punctuation.\n * @returns {string} - The modified text with line breaks added after punctuation.\n */\nexport const insertLineBreaksAfterPunctuation = (text: string): string => {\n // Define the punctuation marks that should trigger a new line\n const punctuation = /([.?!؟])/g;\n\n // Replace occurrences of punctuation marks followed by a space with the punctuation mark, a newline, and the space\n const formattedText = text.replace(punctuation, '$1\\n').replace(/\\n\\s+/g, '\\n').trim();\n\n return formattedText;\n};\n\n/**\n * Adds spaces before and after punctuation, except for certain cases like quoted text or ayah references.\n * Example: 'Text,word' becomes 'Text, word'.\n * @param {string} text - The input text containing punctuation.\n * @returns {string} - The modified text with spaces added before and after punctuation.\n */\nexport const addSpaceBeforeAndAfterPunctuation = (text: string): string => {\n return text\n .replace(/( ?)([.!?,،؟;؛])((?![ '”“\\)\"\\]\\n])|(?=\\s{2,}))/g, '$1$2 ')\n .replace(/\\s([.!?,،؟;؛])\\s*([ '”“\\)\"\\]\\n])/g, '$1$2')\n .replace(/([^\\s\\w\\d'”“\\)\"\\]]+)\\s+([.!?,،؟;؛])|([.!?,،؟;؛])\\s+$/g, '$1$2$3')\n .replace(/(?<=\\D)( ?: ?)(?!(\\d+:)|(:\\d+))|(?<=\\d) ?: ?(?=\\D)|(?<=\\D) ?: ?(?=\\d)/g, ': ');\n};\n\n/**\n * Turns regular double quotes surrounding a body of text into smart quotes.\n * Also fixes incorrect starting quotes by ensuring the string starts with an opening quote if needed.\n * Example: 'The \"quick brown\" fox' becomes 'The “quick brown” fox'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with smart quotes applied.\n */\nexport const applySmartQuotes = (text: string): string => {\n return text\n .replace(/[“”]/g, '\"')\n .replace(/\"([^\"]*)\"/g, '“$1”')\n .replace(/^”/g, '“');\n};\n\n/**\n * Replaces literal new line characters (\\n) and carriage returns (\\r) with actual line breaks.\n * Example: 'A\\\\nB' becomes 'A\\nB'.\n * @param {string} text - The input text containing literal new lines.\n * @returns {string} - The modified text with actual line breaks.\n */\nexport const cleanLiteralNewLines = (text: string): string => {\n return text.replace(/\\\\n|\\r/g, '\\n');\n};\n\n/**\n * Removes trailing spaces from each line in a multiline string.\n * Example: \" This is a line \\nAnother line \" becomes \"This is a line\\nAnother line\".\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with trailing spaces removed.\n */\nexport const cleanMultilines = (text: string): string => {\n return text.replace(/^ +| +$/gm, '');\n};\n\n/**\n * Checks if the input string consists of only punctuation characters.\n * @param {string} text - The input text to check.\n * @returns {boolean} - Returns true if the string contains only punctuation, false otherwise.\n */\nexport const isOnlyPunctuation = (text: string): boolean => {\n const regex = /^[\\u0020-\\u002f\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u007e0-9٠-٩]+$/;\n return regex.test(text);\n};\n\nexport const cleanJunkFromText = (text: string): string => {\n const newBody = cleanMultilines(text);\n const lines = newBody.split('\\n').filter((line) => {\n return !line || (line.length > 1 && !isOnlyPunctuation(line));\n });\n\n return lines.join('\\n').trim();\n};\n\n/**\n * Cleans unnecessary spaces before punctuation marks such as periods, commas, and question marks.\n * Example: 'This is a sentence , with extra space .' becomes 'This is a sentence, with extra space.'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with cleaned spaces before punctuation.\n */\nexport const cleanSpacesBeforePeriod = (text: string): string => {\n return text.replace(/\\s+([.؟!,،؛:?])/g, '$1');\n};\n\n/**\n * Condenses multiple asterisks (*) into a single one.\n * Example: '***' becomes '*'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed asterisks.\n */\nexport const condenseAsterisks = (text: string): string => {\n return text.replace(/(\\*\\s*)+/g, '*');\n};\n\n/**\n * Replaces occurrences of colons surrounded by periods (e.g., '.:.' or ':') with a single colon.\n * Example: 'This.:. is a test' becomes 'This: is a test'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed colons.\n */\nexport const condenseColons = (text: string): string => {\n return text.replace(/[\\.-]?:[\\.-]?/g, ':');\n};\n\n/**\n * Condenses two or more dashes (--) into a single dash (-).\n * Example: 'This is some ---- text' becomes 'This is some - text'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed dashes.\n */\nexport const condenseDashes = (text: string): string => {\n return text.replace(/-{2,}/g, '-');\n};\n\n/**\n * Replaces sequences of two or more periods (e.g., '...') with an ellipsis character (…).\n * Example: 'This is a test...' becomes 'This is a test…'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with ellipses condensed.\n */\nexport const condenseEllipsis = (text: string): string => {\n return text.replace(/\\.{2,}/g, '…');\n};\n\n/**\n * Reduces multiple consecutive line breaks (3 or more) to exactly 2 line breaks.\n * Example: 'This is line 1\\n\\n\\n\\nThis is line 2' becomes 'This is line 1\\n\\nThis is line 2'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed line breaks.\n */\nexport const reduceMultilineBreaksToDouble = (text: string): string => {\n return text.replace(/(\\n\\s*){3,}/g, '\\n\\n');\n};\n\n/**\n * Reduces multiple consecutive line breaks (2 or more) to exactly 1 line break.\n * Example: 'This is line 1\\n\\nThis is line 2' becomes 'This is line 1\\nThis is line 2'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed line breaks.\n */\nexport const reduceMultilineBreaksToSingle = (text: string): string => {\n return text.replace(/(\\n\\s*){2,}/g, '\\n');\n};\n\n/**\n * Condenses multiple periods separated by spaces (e.g., '. . .') into a single period.\n * Example: 'This . . . is a test' becomes 'This. is a test'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed periods.\n */\nexport const condensePeriods = (text: string): string => {\n return text.replace(/\\. +\\./g, '.');\n};\n\n/**\n * Condenses multiple underscores (__) or Arabic Tatweel characters (ـــــ) into a single underscore or Tatweel.\n * Example: 'This is ـــ some text __' becomes 'This is ـ some text _'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed underscores.\n */\nexport const condenseUnderscores = (text: string): string => {\n return text.replace(/ـ{2,}/g, 'ـ').replace(/_+/g, '_');\n};\n\n/**\n * Replaces double parentheses or brackets with single ones.\n * Example: '((text))' becomes '(text)'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed brackets.\n */\nexport const doubleToSingleBrackets = (text: string): string => {\n return text.replace(/(\\(|\\)){2,}|(\\[|\\]){2,}/g, '$1$2');\n};\n\n/**\n * Formats a multiline string by joining sentences and maintaining footnotes on their own lines.\n * Footnotes are identified by Arabic and English numerals.\n * Example: 'Sentence one.\\n(1) A footnote.\\nSentence two.' remains the same, while regular sentences are joined.\n * @param {string} input - The input text containing sentences and footnotes.\n * @returns {string} - The formatted text.\n */\nexport const formatStringBySentence = (input: string): string => {\n const footnoteRegex = /^\\((?:\\d+|۱|۲|۳|۴|۵|۶|۷|۸|۹)\\)\\s/;\n const sentences: string[] = [];\n const lines = input.split('\\n');\n let currentSentence = '';\n\n lines.forEach((line) => {\n const trimmedLine = line.trim();\n const isFootnote = footnoteRegex.test(trimmedLine);\n const isNumber = /^\\(\\d+\\/\\d+\\)/.test(trimmedLine);\n\n if (isFootnote && !isNumber) {\n if (currentSentence) {\n sentences.push(currentSentence.trim());\n currentSentence = '';\n }\n sentences.push(trimmedLine);\n } else {\n currentSentence += `${trimmedLine} `;\n const lastChar = currentSentence.trim().slice(-1);\n if (/[.!؟]/.test(lastChar)) {\n sentences.push(currentSentence.trim());\n currentSentence = '';\n }\n }\n });\n\n // Add any remaining text to the output\n if (currentSentence) {\n sentences.push(currentSentence.trim());\n }\n\n return sentences.join('\\n');\n};\n\n/**\n * Removes unnecessary spaces around slashes in references.\n * Example: '127 / 11' becomes '127/11'.\n * @param {string} text - The input text containing references.\n * @returns {string} - The modified text with spaces removed around slashes.\n */\nexport const normalizeSlashInReferences = (text: string): string => {\n return text.replace(/(\\d+)\\s?\\/\\s?(\\d+)/g, '$1/$2');\n};\n\n/**\n * Reduces multiple spaces or tabs to a single space.\n * Example: 'This is a text' becomes 'This is a text'.\n * @param {string} text - The input text containing extra spaces.\n * @returns {string} - The modified text with reduced spaces.\n */\nexport const normalizeSpaces = (text: string): string => {\n return text.replace(/[ \\t]+/g, ' ');\n};\n\n/**\n * Removes spaces inside brackets, parentheses, or square brackets.\n * Example: '( a b )' becomes '(a b)'.\n * @param {string} text - The input text with spaces inside brackets.\n * @returns {string} - The modified text with spaces removed inside brackets.\n */\nexport const removeSpaceInsideBrackets = (text: string): string => {\n return text.replace(/([\\[\\(])\\s*(.*?)\\s*([\\]\\)])/g, '$1$2$3');\n};\n\n/**\n * Removes bold styling from text by normalizing the string and removing stylistic characters.\n * @param {string} text - The input text containing bold characters.\n * @returns {string} - The modified text with bold styling removed.\n */\nexport const stripBoldStyling = (text: string): string => {\n // Normalize the string to NFKD form\n const normalizedString = text.normalize('NFKD');\n\n // Remove combining marks (diacritics) and stylistic characters from the string\n return normalizedString.replace(/[\\u0300-\\u036f]/g, '').trim();\n};\n\n/**\n * Removes italicized characters by replacing italic Unicode characters with their normal counterparts.\n * Example: '𝘼𝘽𝘾' becomes 'ABC'.\n * @param {string} text - The input text containing italicized characters.\n * @returns {string} - The modified text with italics removed.\n */\nexport const stripItalicsStyling = (text: string): string => {\n const italicMap: Record<string, string> = {\n '\\uD835\\uDC46': 'A',\n '\\uD835\\uDC47': 'B',\n '\\uD835\\uDC48': 'C',\n '\\uD835\\uDC49': 'D',\n '\\uD835\\uDC4A': 'E',\n '\\uD835\\uDC4B': 'F',\n '\\uD835\\uDC4C': 'G',\n '\\uD835\\uDC4D': 'H',\n '\\uD835\\uDC4E': 'I',\n '\\uD835\\uDC4F': 'J',\n '\\uD835\\uDC50': 'K',\n '\\uD835\\uDC51': 'L',\n '\\uD835\\uDC52': 'M',\n '\\uD835\\uDC53': 'N',\n '\\uD835\\uDC54': 'O',\n '\\uD835\\uDC55': 'P',\n '\\uD835\\uDC56': 'Q',\n '\\uD835\\uDC57': 'R',\n '\\uD835\\uDC58': 'S',\n '\\uD835\\uDC59': 'T',\n '\\uD835\\uDC5A': 'U',\n '\\uD835\\uDC5B': 'V',\n '\\uD835\\uDC5C': 'W',\n '\\uD835\\uDC5D': 'X',\n '\\uD835\\uDC5E': 'Y',\n '\\uD835\\uDC5F': 'Z',\n '\\uD835\\uDC62': 'a',\n '\\uD835\\uDC63': 'b',\n '\\uD835\\uDC64': 'c',\n '\\uD835\\uDC65': 'd',\n '\\uD835\\uDC66': 'e',\n '\\uD835\\uDC67': 'f',\n '\\uD835\\uDC68': 'g',\n '\\uD835\\uDC69': 'h',\n '\\uD835\\uDC6A': 'i',\n '\\uD835\\uDC6B': 'j',\n '\\uD835\\uDC6C': 'k',\n '\\uD835\\uDC6D': 'l',\n '\\uD835\\uDC6E': 'm',\n '\\uD835\\uDC6F': 'n',\n '\\uD835\\uDC70': 'o',\n '\\uD835\\uDC71': 'p',\n '\\uD835\\uDC72': 'q',\n '\\uD835\\uDC73': 'r',\n '\\uD835\\uDC74': 's',\n '\\uD835\\uDC75': 't',\n '\\uD835\\uDC76': 'u',\n '\\uD835\\uDC77': 'v',\n '\\uD835\\uDC78': 'w',\n '\\uD835\\uDC79': 'x',\n '\\uD835\\uDC7A': 'y',\n '\\uD835\\uDC7B': 'z',\n '\\u{1D63C}': '!',\n '\\u{1D63D}': '?',\n '\\u{1D63F}': ',',\n '\\u{1D640}': '.',\n '\\u{1D647}': '-',\n };\n\n return text.replace(/[\\uD835\\uDC62-\\uD835\\uDC7B\\uD835\\uDC46-\\uD835\\uDC5F\\u{1D63C}-\\u{1D647}]/gu, (match) => {\n return italicMap[match] || match;\n });\n};\n\n/**\n * Removes all bold and italic styling from the input text.\n * @param {string} text - The input text to remove styling from.\n * @returns {string} - The modified text with all styling removed.\n */\nexport const stripStyling = (text: string): string => {\n return stripItalicsStyling(stripBoldStyling(text));\n};\n\n/**\n * Removes unnecessary spaces inside quotes.\n * Example: '“ Text ”' becomes '“Text”'.\n * @param {string} text - The input text with spaces inside quotes.\n * @returns {string} - The modified text with spaces removed inside quotes.\n */\nexport const trimSpaceInsideQuotes = (text: string): string => {\n return text.replace(/([“”\"]|«) *(.*?) *([“”\"]|»)/g, '$1$2$3');\n};\n","/**\n * Converts a string that resembles JSON but with numeric keys and single-quoted values\n * into valid JSON format. This function replaces numeric keys with quoted numeric keys\n * and ensures all values are double-quoted as required by JSON.\n *\n * @param {string} str - The input string that needs to be fixed into valid JSON.\n * @returns {string} - A valid JSON string.\n *\n * @example\n * const result = normalizeJsonSyntax(\"{10: 'abc', 20: 'def'}\");\n * console.log(result); // '{\"10\": \"abc\", \"20\": \"def\"}'\n */\nexport const normalizeJsonSyntax = (str: string): string => {\n let input = str.replace(/(\\b\\d+\\b)(?=:)/g, '\"$1\"');\n input = input.replace(/:\\s*'([^']+)'/g, ': \"$1\"');\n input = input.replace(/:\\s*\"([^\"]+)\"/g, ': \"$1\"');\n\n return JSON.stringify(JSON.parse(input));\n};\n\n/**\n * Checks if a given string resembles a JSON object with numeric or quoted keys and values\n * that are single or double quoted. This is useful for detecting malformed JSON-like\n * structures that can be fixed by the `normalizeJsonSyntax` function.\n *\n * @param {string} str - The input string to check.\n * @returns {boolean} - Returns true if the string is JSON-like, false otherwise.\n *\n * @example\n * const result = isJsonStructureValid(\"{10: 'abc', 'key': 'value'}\");\n * console.log(result); // true\n */\nexport const isJsonStructureValid = (str: string): boolean => {\n // Checks for a pattern with numeric keys or quoted keys and values in quotes\n const jsonLikePattern =\n /^{(\\s*(\\d+|'[^']*'|\"[^\"]*\")\\s*:\\s*('|\")[^'\"]*\\3\\s*,)*(?:\\s*(\\d+|'[^']*'|\"[^\"]*\")\\s*:\\s*('|\")[^'\"]*\\5\\s*)}$/;\n return jsonLikePattern.test(str.trim());\n};\n\n/**\n * Splits a string by spaces and quoted substrings.\n *\n * This function takes an input string and splits it into parts where substrings\n * enclosed in double quotes are treated as a single part. Other substrings\n * separated by spaces are split normally.\n *\n * @param {string} query - The input string to be split.\n * @returns {string[]} An array of strings, with quoted substrings kept intact.\n *\n * @example\n * const result = splitByQuotes('\"This is\" \"a part of the\" \"string and\"');\n * console.log(result); // [\"This is\", \"a part of the\", \"string and\"]\n */\nexport const splitByQuotes = (query: string): string[] => {\n const regex = /(?:[^\\s\"]+|\"(.*?)\")+/g;\n return (query.match(regex) || []).map((s: string) => (s.startsWith('\"') ? s.slice(1, -1) : s));\n};\n","/**\n * Removes various symbols, part references, and numerical markers from the text.\n * Example: '(1) (2/3)' becomes ''.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with symbols and part references removed.\n */\nexport const cleanSymbolsAndPartReferences = (text: string): string => {\n return text.replace(\n / *\\(?:\\d+(?:\\/\\d+){0,2}\\)? *| *\\[\\d+(?:\\/\\d+)?\\] *| *«\\d+» *|\\d+\\/\\d+(?:\\/\\d+)?|[،§{}؍﴿﴾<>;_؟»«:!،؛\\[\\]…ـ¬\\.\\\\\\/\\*\\(\\)\"]/g,\n ' ',\n );\n};\n\n/**\n * Removes trailing page numbers formatted as '-[46]-' from the text.\n * Example: 'This is some -[46]- text' becomes 'This is some text'.\n * @param {string} text - The input text with trailing page numbers.\n * @returns {string} - The modified text with page numbers removed.\n */\nexport const cleanTrailingPageNumbers = (text: string): string => {\n return text.replace(/-\\[\\d+\\]-/g, '');\n};\n\n/**\n * Replaces consecutive line breaks and whitespace characters with a single space.\n * Example: 'a\\nb' becomes 'a b'.\n * @param {string} text - The input text containing line breaks or multiple spaces.\n * @returns {string} - The modified text with spaces.\n */\nexport const replaceLineBreaksWithSpaces = (text: string): string => {\n return text.replace(/\\s+/g, ' ');\n};\n\n/**\n * Removes all numeric digits from the text.\n * Example: 'abc123' becomes 'abc'.\n * @param {string} text - The input text containing digits.\n * @returns {string} - The modified text with digits removed.\n */\nexport const stripAllDigits = (text: string): string => {\n return text.replace(/[0-9]/g, '');\n};\n\n/**\n * Removes death year references like \"(d. 390H)\" and \"[d. 100h]\" from the text.\n * Example: 'Sufyān ibn ‘Uyaynah (d. 198h)' becomes 'Sufyān ibn ‘Uyaynah'.\n * @param {string} text - The input text containing death year references.\n * @returns {string} - The modified text with death years removed.\n */\nexport const removeDeathYear = (text: string): string => {\n return text.replace(/\\[(d)\\.\\s*\\d{1,4}[hH]\\]\\s*|\\((d)\\.\\s*\\d{1,4}[hH]\\)\\s*/g, '');\n};\n\n/**\n * Removes numeric digits and dashes from the text.\n * Example: 'ABC 123-Xyz' becomes 'ABC Xyz'.\n * @param {string} text - The input text containing digits and dashes.\n * @returns {string} - The modified text with numbers and dashes removed.\n */\nexport const removeNumbersAndDashes = (text: string): string => {\n return text.replace(/[\\d-]/g, '');\n};\n\n/**\n * Removes single digit references like (1), «2», [3] from the text.\n * Example: 'Ref (1), Ref «2», Ref [3]' becomes 'Ref , Ref , Ref '.\n * @param {string} text - The input text containing single digit references.\n * @returns {string} - The modified text with single digit references removed.\n */\nexport const removeSingleDigitReferences = (text: string): string => {\n return text.replace(/\\(\\d{1}\\)|\\[\\d{1}\\]|«\\d»/g, '');\n};\n\n/**\n * Removes URLs from the text.\n * Example: 'Visit https://example.com' becomes 'Visit '.\n * @param {string} text - The input text containing URLs.\n * @returns {string} - The modified text with URLs removed.\n */\nexport const removeUrls = (text: string): string => {\n return text.replace(\n /https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g,\n '',\n );\n};\n","import { normalizeSpaces } from './formatting';\n\n/**\n * Replaces common Arabic prefixes (like 'Al-', 'Ar-', 'Ash-', etc.) with 'al-' in the text.\n * Handles different variations of prefixes such as Ash- and Al- but not when the second word\n * does not start with 'S'.\n * Example: 'Ash-Shafiee' becomes 'al-Shafiee'.\n *\n * @param {string} text - The input text containing Arabic prefixes.\n * @returns {string} - The modified text with standardized 'al-' prefixes.\n */\nexport const normalizeArabicPrefixesToAl = (text: string): string => {\n return text\n .replace(/(\\b|\\W)(Al |Al-|Ar-|As-|Adh-|Ad-|Ats-|Ath |Ath-|Az |Az-|az-|adh-|as-|ar-)/g, '$1al-')\n .replace(/(\\b|\\W)(Ash-S|ash-S)/g, '$1al-S')\n .replace(/al- (.+?)\\b/g, 'al-$1');\n};\n\n/**\n * Removes double occurrences of Arabic apostrophes such as ʿʿ or ʾʾ in the text.\n * Example: 'ʿulamāʾʾ' becomes 'ʿulamāʾ'.\n *\n * @param {string} text - The input text containing double apostrophes.\n * @returns {string} - The modified text with condensed apostrophes.\n */\nexport const normalizeDoubleApostrophes = (text: string): string => {\n return text.replace(/ʿʿ/g, 'ʿ').replace(/ʾʾ/g, 'ʾ');\n};\n\n/**\n * Replaces common salutations such as \"sallahu alayhi wasallam\" with \"ﷺ\" in the text.\n * It also handles variations of the salutation phrase, including 'peace and blessings be upon him'.\n * Example: 'Then Muḥammad (sallahu alayhi wasallam)' becomes 'Then Muḥammad ﷺ'.\n *\n * @param {string} text - The input text containing salutations.\n * @returns {string} - The modified text with salutations replaced.\n */\nexport const replaceSalutationsWithSymbol = (text: string): string => {\n return text\n .replace(\n /\\(peace be upon him\\)|(Messenger of (Allah|Allāh)|Messenger|Prophet|Mu[hḥ]ammad) *\\((s[^)]*m|peace[^)]*him|May[^)]*him|may[^)]*him)\\)*/gi,\n '$1 ﷺ',\n )\n .replace(/,\\s*ﷺ\\s*,/g, ' ﷺ');\n};\n\n/**\n * Normalizes the text by removing diacritics, apostrophes, and dashes.\n * Example: 'Al-Jadwal' becomes 'AlJadwal'.\n *\n * @param {string} input - The input text to normalize.\n * @returns {string} - The normalized text.\n */\nexport const normalize = (input: string) => {\n return input\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .replace(/`|ʾ|ʿ|-/g, '');\n};\n\n/**\n * Replaces various apostrophe characters (‛, ’, ‘) with the standard apostrophe (').\n * Example: '‛ulama’ al-su‘' becomes ''ulama' al-su''.\n *\n * @param {string} text - The input text containing different apostrophe characters.\n * @returns {string} - The modified text with normalized apostrophes.\n */\nexport const normalizeApostrophes = (text: string): string => {\n return text.replace(/‛|’|‘/g, \"'\");\n};\n\n/**\n * Strips common Arabic prefixes like 'al-', 'bi-', 'fī', 'wa-', etc. from the beginning of words.\n * Example: 'al-Bukhari' becomes 'Bukhari'.\n *\n * @param {string} text - The input text containing Arabic prefixes.\n * @returns {string} - The modified text with prefixes stripped.\n */\nexport const removeArabicPrefixes = (text: string): string => {\n return normalizeSpaces(text.replace(/(\\bal-|\\bli-|\\bbi-|\\bfī|\\bwa[-\\s]+|\\bl-|\\bliʿl|\\Bʿalá|\\Bʿan|\\bb\\.)/gi, ''));\n};\n\n/**\n * Simplifies English transliterations by removing diacritics, apostrophes, and common prefixes.\n * Example: 'Al-Jadwal' becomes 'Jadwal', and 'āḍġḥīṣṭū' becomes 'adghistu'.\n *\n * @param {string} text - The input text to simplify.\n * @returns {string} - The simplified text.\n */\nexport const normalizeTransliteratedEnglish = (text: string): string => normalize(removeArabicPrefixes(text));\n\n/**\n * Extracts the initials from the input string, typically used for names or titles.\n * Example: 'Nayl al-Awtar' becomes 'NA'.\n *\n * @param {string} text - The input text to extract initials from.\n * @returns {string} - The extracted initials.\n */\nexport const extractInitials = (fullName: string) => {\n const initials = normalizeTransliteratedEnglish(fullName)\n .trim()\n .split(/[ -]/)\n .slice(0, 2)\n .map((word) => {\n return word.charAt(0).toUpperCase();\n })\n .join('');\n return initials;\n};\n"],"names":[],"version":3,"file":"main.js.map","sourceRoot":"../"}
|
|
1
|
+
{"mappings":";;;;;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CAAC,6BAA6B;AACrD;AAQO,MAAM,4CAAa,CAAC;IACvB,OAAO,KAAK,OAAO,CACf,wGACA;AAER;;;;;;;;;;;;;;ACzEO,MAAM,4CAA8B,CAAC;IACxC,OAAO,KACF,OAAO,CAAC,8EAA8E,SACtF,OAAO,CAAC,yBAAyB,UACjC,OAAO,CAAC,gBAAgB;AACjC;AASO,MAAM,4CAA6B,CAAC;IACvC,OAAO,KAAK,OAAO,CAAC,OAAO,UAAK,OAAO,CAAC,OAAO;AACnD;AAUO,MAAM,4CAA+B,CAAC;IACzC,OAAO,KACF,OAAO,CACJ,4IACA,aAEH,OAAO,CAAC,cAAc;AAC/B;AASO,MAAM,0CAAY,CAAC;IACtB,OAAO,MACF,SAAS,CAAC,QACV,OAAO,CAAC,oBAAoB,IAC5B,OAAO,CAAC,YAAY;AAC7B;AASO,MAAM,4CAAuB,CAAC;IACjC,OAAO,KAAK,OAAO,CAAC,UAAU;AAClC;AASO,MAAM,4CAAuB,CAAC;IACjC,OAAO,CAAA,GAAA,yCAAc,EAAE,KAAK,OAAO,CAAC,wEAAwE;AAChH;AASO,MAAM,4CAAiC,CAAC,OAAyB,wCAAU,0CAAqB;AAShG,MAAM,4CAAkB,CAAC;IAC5B,MAAM,WAAW,0CAA+B,UAC3C,IAAI,GACJ,KAAK,CAAC,QACN,KAAK,CAAC,GAAG,GACT,GAAG,CAAC,CAAC;QACF,OAAO,KAAK,MAAM,CAAC,GAAG,WAAW;IACrC,GACC,IAAI,CAAC;IACV,OAAO;AACX;","sources":["src/index.ts","src/arabic.ts","src/formatting.ts","src/parsing.ts","src/sanitization.ts","src/transliteration.ts"],"sourcesContent":["export * from './arabic';\nexport * from './formatting';\nexport * from './parsing';\nexport * from './sanitization';\nexport * from './transliteration';\n","/**\n * Removes extreme Arabic underscores (ـ) that appear at the beginning or end of a line or in text.\n * Does not affect Hijri dates (e.g., 1424هـ) or specific Arabic terms.\n * Example: \"ـThis is a textـ\" will be changed to \"This is a text\".\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with extreme underscores removed.\n */\nexport const cleanExtremeArabicUnderscores = (text: string): string => {\n return text.replace(/(?<!\\d ?ه|اه)ـ(?=\\r?$)|^ـ(?!اهـ)/gm, '');\n};\n\n/**\n * Converts Urdu symbols to their Arabic equivalents.\n * Example: 'ھذا' will be changed to 'هذا', 'ی' to 'ي'.\n * @param {string} text - The input text containing Urdu symbols.\n * @returns {string} - The modified text with Urdu symbols converted to Arabic symbols.\n */\nexport const convertUrduSymbolsToArabic = (text: string): string => {\n return text.replace(/ھ/g, 'ه').replace(/ی/g, 'ي');\n};\n\n/**\n * Fixes the trailing \"و\" (wow) in phrases such as \"عليكم و رحمة\" to \"عليكم ورحمة\".\n * This function attempts to correct phrases where \"و\" appears unnecessarily, particularly in greetings.\n * Example: 'السلام عليكم و رحمة' will be changed to 'السلام عليكم ورحمة'.\n * @param {string} text - The input text containing the \"و\" character.\n * @returns {string} - The modified text with unnecessary trailing \"و\" characters corrected.\n */\nexport const fixTrailingWow = (text: string): string => {\n return text.replace(/ و /g, ' و');\n};\n\n/**\n * Inserts a space between Arabic text and numbers.\n * Example: 'الآية37' will be changed to 'الآية 37'.\n * @param {string} text - The input text containing Arabic text followed by numbers.\n * @returns {string} - The modified text with spaces inserted between Arabic text and numbers.\n */\nexport const addSpaceBetweenArabicTextAndNumbers = (text: string): string => {\n return text.replace(/([\\u0600-\\u06FF]+)(\\d+)/g, '$1 $2');\n};\n\n/**\n * Removes English letters and symbols from the text, including ampersands, slashes, and other symbols.\n * Example: 'أحب & لنفسي' will be changed to 'أحب لنفسي'.\n * @param {string} text - The input text containing English letters and symbols.\n * @returns {string} - The modified text with English letters and symbols removed.\n */\nexport const stripEnglishCharactersAndSymbols = (text: string): string => {\n return text.replace(/[a-zA-Z]+[0-9]*|[¬§`ﷺ=]|\\/{2,}|&/g, ' ');\n};\n\n/**\n * Removes single-digit numbers surrounded by Arabic text. Also removes dashes (-) not followed by a number.\n * For example, removes '3' from 'وهب 3 وقال' but does not remove '121' from 'لوحه 121 الجرح'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with non-index numbers and dashes removed.\n */\nexport const removeNonIndexSignatures = (text: string): string => {\n return text\n .replace(/(?<![0-9] ?)-|(?<=[\\u0600-\\u06FF])\\s?\\d\\s?(?=[\\u0600-\\u06FF])/g, ' ')\n .replace(/(?<=[\\u0600-\\u06FF]\\s)(\\d+\\s)+\\d+(?=(\\s[\\u0600-\\u06FF]|$))/g, ' ');\n};\n\n/**\n * Removes characters enclosed in square brackets [] or parentheses () if they are Arabic letters or Arabic-Indic numerals.\n * Example: '[س]' or '(س)' will be removed.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with singular codes removed.\n */\nexport const removeSingularCodes = (text: string): string => {\n return text.replace(/[\\[\\({][\\u0621-\\u064A\\u0660-\\u0669][\\]\\)}]/g, '');\n};\n\n/**\n * Removes solitary Arabic letters unless they are the 'ha' letter, which is used in Hijri years.\n * Example: \"ب ا الكلمات ت\" will be changed to \"ا الكلمات\".\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with solitary Arabic letters removed.\n */\nexport const removeSolitaryArabicLetters = (text: string): string => {\n return text.replace(/(^| )[\\u0621-\\u064A]( |$)/g, ' ');\n};\n\n/**\n * Removes tatweel characters while preserving dates references.\n * Example: \"1435/3/29 هـ\" remains as \"1435/3/29 هـ\" but \"أبـــتِـــكَةُ\" becomes \"أبتِكَةُ\"\n * @param text The text to format.\n * @returns The modified text with the tatweel characters removed.\n */\nexport const removeTatwil = (text: string) => {\n return text.replace(/(?<![0-9ه])ـ/g, '');\n};\n\n/**\n * Replaces the 'tah marbutah' (ة) character with 'ha' (ه).\n * Example: 'مدرسة' will be changed to 'مدرسه'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with 'ta marbutah' replaced by 'ha'.\n */\nexport const replaceTaMarbutahWithHa = (text: string): string => {\n return text.replace(/[ة]/g, 'ه');\n};\n\n/**\n * Removes Arabic diacritics (tashkeel) and the tatweel (elongation) character.\n * Example: 'مُحَمَّدٌ' will be changed to 'محمد'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with diacritics and tatweel removed.\n */\nexport const stripDiacritics = (text: string): string => {\n return text.replace(\n /[\\u0610\\u0611\\u0612\\u0613\\u0614\\u0615\\u0616\\u0617\\u0618\\u0619\\u061A\\u064B\\u064C\\u064D\\u064E\\u064F\\u0650\\u0651\\u0652\\u0653\\u0654\\u0655\\u0656\\u0657\\u0658\\u065A\\u065B\\u065C\\u065D\\u065E\\u0640]/g,\n '',\n );\n};\n\n/**\n * Removes zero-width joiners (ZWJ) and other zero-width characters from the input text.\n * Zero-width characters include U+200B to U+200F, U+202A to U+202E, U+2060 to U+2064, and U+FEFF.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with zero-width characters removed.\n */\nexport const stripZeroWidthCharacters = (text: string): string => {\n return text.replace(/[\\u200B-\\u200F\\u202A-\\u202E\\u2060-\\u2064\\uFEFF]/g, ' ');\n};\n\n/**\n * Replaces the 'alif maqsurah' (ى) character with the regular 'ya' (ي).\n * Example: 'رؤيى' will be changed to 'رؤيي'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with 'alif maqsurah' replaced by 'ya'.\n */\nexport const replaceAlifMaqsurah = (text: string): string => {\n return text.replace(/[ىي]/g, 'ي');\n};\n\n/**\n * Replaces English punctuation (question mark and semicolon) with their Arabic equivalents.\n * Example: '?' will be replaced with '؟', and ';' with '؛'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with English punctuation replaced by Arabic punctuation.\n */\nexport const replaceEnglishPunctuationWithArabic = (text: string): string => {\n return text\n .replace(/\\?|؟\\./g, '؟')\n .replace(/(;|؛)\\s*(\\1\\s*)*/g, '؛')\n .replace(/,|-،/g, '،');\n};\n\n/**\n * Simplifies all forms of 'alif' (أ, إ, and آ) to the basic 'ا'.\n * Example: 'أنا إلى الآفاق' will be changed to 'انا الى الافاق'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with simplified 'alif' characters.\n */\nexport const normalizeAlifVariants = (text: string): string => {\n return text.replace(/[أإآ]/g, 'ا');\n};\n","/**\n * Adds line breaks after punctuation marks such as periods, exclamation points, and question marks.\n * Example: 'Text.' becomes 'Text.\\n'.\n * @param {string} text - The input text containing punctuation.\n * @returns {string} - The modified text with line breaks added after punctuation.\n */\nexport const insertLineBreaksAfterPunctuation = (text: string): string => {\n // Define the punctuation marks that should trigger a new line\n const punctuation = /([.?!؟])/g;\n\n // Replace occurrences of punctuation marks followed by a space with the punctuation mark, a newline, and the space\n const formattedText = text.replace(punctuation, '$1\\n').replace(/\\n\\s+/g, '\\n').trim();\n\n return formattedText;\n};\n\n/**\n * Adds spaces before and after punctuation, except for certain cases like quoted text or ayah references.\n * Example: 'Text,word' becomes 'Text, word'.\n * @param {string} text - The input text containing punctuation.\n * @returns {string} - The modified text with spaces added before and after punctuation.\n */\nexport const addSpaceBeforeAndAfterPunctuation = (text: string): string => {\n return text\n .replace(/( ?)([.!?,،؟;؛])((?![ '”“\\)\"\\]\\n])|(?=\\s{2,}))/g, '$1$2 ')\n .replace(/\\s([.!?,،؟;؛])\\s*([ '”“\\)\"\\]\\n])/g, '$1$2')\n .replace(/([^\\s\\w\\d'”“\\)\"\\]]+)\\s+([.!?,،؟;؛])|([.!?,،؟;؛])\\s+$/g, '$1$2$3')\n .replace(/(?<=\\D)( ?: ?)(?!(\\d+:)|(:\\d+))|(?<=\\d) ?: ?(?=\\D)|(?<=\\D) ?: ?(?=\\d)/g, ': ');\n};\n\n/**\n * Turns regular double quotes surrounding a body of text into smart quotes.\n * Also fixes incorrect starting quotes by ensuring the string starts with an opening quote if needed.\n * Example: 'The \"quick brown\" fox' becomes 'The “quick brown” fox'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with smart quotes applied.\n */\nexport const applySmartQuotes = (text: string): string => {\n return text\n .replace(/[“”]/g, '\"')\n .replace(/\"([^\"]*)\"/g, '“$1”')\n .replace(/^”/g, '“');\n};\n\n/**\n * Replaces literal new line characters (\\n) and carriage returns (\\r) with actual line breaks.\n * Example: 'A\\\\nB' becomes 'A\\nB'.\n * @param {string} text - The input text containing literal new lines.\n * @returns {string} - The modified text with actual line breaks.\n */\nexport const cleanLiteralNewLines = (text: string): string => {\n return text.replace(/\\\\n|\\r/g, '\\n');\n};\n\n/**\n * Removes trailing spaces from each line in a multiline string.\n * Example: \" This is a line \\nAnother line \" becomes \"This is a line\\nAnother line\".\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with trailing spaces removed.\n */\nexport const cleanMultilines = (text: string): string => {\n return text.replace(/^ +| +$/gm, '');\n};\n\n/**\n * Detects if a word is by itself in a line.\n * @param text The text to check.\n * @returns true if there exists a word in any of the lines in the text that is by itself.\n */\nexport const hasWordInSingleLine = (text: string): boolean => {\n return /^\\s*\\S+\\s*$/gm.test(text);\n};\n\n/**\n * Checks if the input string consists of only punctuation characters.\n * @param {string} text - The input text to check.\n * @returns {boolean} - Returns true if the string contains only punctuation, false otherwise.\n */\nexport const isOnlyPunctuation = (text: string): boolean => {\n const regex = /^[\\u0020-\\u002f\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u007e0-9٠-٩]+$/;\n return regex.test(text);\n};\n\nexport const cleanJunkFromText = (text: string): string => {\n const newBody = cleanMultilines(text);\n const lines = newBody.split('\\n').filter((line) => {\n return !line || (line.length > 1 && !isOnlyPunctuation(line));\n });\n\n return lines.join('\\n').trim();\n};\n\n/**\n * Cleans unnecessary spaces before punctuation marks such as periods, commas, and question marks.\n * Example: 'This is a sentence , with extra space .' becomes 'This is a sentence, with extra space.'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with cleaned spaces before punctuation.\n */\nexport const cleanSpacesBeforePeriod = (text: string): string => {\n return text.replace(/\\s+([.؟!,،؛:?])/g, '$1');\n};\n\n/**\n * Condenses multiple asterisks (*) into a single one.\n * Example: '***' becomes '*'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed asterisks.\n */\nexport const condenseAsterisks = (text: string): string => {\n return text.replace(/(\\*\\s*)+/g, '*');\n};\n\n/**\n * Replaces occurrences of colons surrounded by periods (e.g., '.:.' or ':') with a single colon.\n * Example: 'This.:. is a test' becomes 'This: is a test'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed colons.\n */\nexport const condenseColons = (text: string): string => {\n return text.replace(/[\\.-]?:[\\.-]?/g, ':');\n};\n\n/**\n * Condenses two or more dashes (--) into a single dash (-).\n * Example: 'This is some ---- text' becomes 'This is some - text'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed dashes.\n */\nexport const condenseDashes = (text: string): string => {\n return text.replace(/-{2,}/g, '-');\n};\n\n/**\n * Replaces sequences of two or more periods (e.g., '...') with an ellipsis character (…).\n * Example: 'This is a test...' becomes 'This is a test…'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with ellipses condensed.\n */\nexport const condenseEllipsis = (text: string): string => {\n return text.replace(/\\.{2,}/g, '…');\n};\n\n/**\n * Reduces multiple consecutive line breaks (3 or more) to exactly 2 line breaks.\n * Example: 'This is line 1\\n\\n\\n\\nThis is line 2' becomes 'This is line 1\\n\\nThis is line 2'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed line breaks.\n */\nexport const reduceMultilineBreaksToDouble = (text: string): string => {\n return text.replace(/(\\n\\s*){3,}/g, '\\n\\n');\n};\n\n/**\n * Reduces multiple consecutive line breaks (2 or more) to exactly 1 line break.\n * Example: 'This is line 1\\n\\nThis is line 2' becomes 'This is line 1\\nThis is line 2'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed line breaks.\n */\nexport const reduceMultilineBreaksToSingle = (text: string): string => {\n return text.replace(/(\\n\\s*){2,}/g, '\\n');\n};\n\n/**\n * Condenses multiple periods separated by spaces (e.g., '. . .') into a single period.\n * Example: 'This . . . is a test' becomes 'This. is a test'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed periods.\n */\nexport const condensePeriods = (text: string): string => {\n return text.replace(/\\. +\\./g, '.');\n};\n\n/**\n * Condenses multiple underscores (__) or Arabic Tatweel characters (ـــــ) into a single underscore or Tatweel.\n * Example: 'This is ـــ some text __' becomes 'This is ـ some text _'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed underscores.\n */\nexport const condenseUnderscores = (text: string): string => {\n return text.replace(/ـ{2,}/g, 'ـ').replace(/_+/g, '_');\n};\n\n/**\n * Replaces double parentheses or brackets with single ones.\n * Example: '((text))' becomes '(text)'.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with condensed brackets.\n */\nexport const doubleToSingleBrackets = (text: string): string => {\n return text.replace(/(\\(|\\)){2,}|(\\[|\\]){2,}/g, '$1$2');\n};\n\n/**\n * Formats a multiline string by joining sentences and maintaining footnotes on their own lines.\n * Footnotes are identified by Arabic and English numerals.\n * Example: 'Sentence one.\\n(1) A footnote.\\nSentence two.' remains the same, while regular sentences are joined.\n * @param {string} input - The input text containing sentences and footnotes.\n * @returns {string} - The formatted text.\n */\nexport const formatStringBySentence = (input: string): string => {\n const footnoteRegex = /^\\((?:\\d+|۱|۲|۳|۴|۵|۶|۷|۸|۹)\\)\\s/;\n const sentences: string[] = [];\n const lines = input.split('\\n');\n let currentSentence = '';\n\n lines.forEach((line) => {\n const trimmedLine = line.trim();\n const isFootnote = footnoteRegex.test(trimmedLine);\n const isNumber = /^\\(\\d+\\/\\d+\\)/.test(trimmedLine);\n\n if (isFootnote && !isNumber) {\n if (currentSentence) {\n sentences.push(currentSentence.trim());\n currentSentence = '';\n }\n sentences.push(trimmedLine);\n } else {\n currentSentence += `${trimmedLine} `;\n const lastChar = currentSentence.trim().slice(-1);\n if (/[.!؟]/.test(lastChar)) {\n sentences.push(currentSentence.trim());\n currentSentence = '';\n }\n }\n });\n\n // Add any remaining text to the output\n if (currentSentence) {\n sentences.push(currentSentence.trim());\n }\n\n return sentences.join('\\n');\n};\n\n/**\n * Removes unnecessary spaces around slashes in references.\n * Example: '127 / 11' becomes '127/11'.\n * @param {string} text - The input text containing references.\n * @returns {string} - The modified text with spaces removed around slashes.\n */\nexport const normalizeSlashInReferences = (text: string): string => {\n return text.replace(/(\\d+)\\s?\\/\\s?(\\d+)/g, '$1/$2');\n};\n\n/**\n * Reduces multiple spaces or tabs to a single space.\n * Example: 'This is a text' becomes 'This is a text'.\n * @param {string} text - The input text containing extra spaces.\n * @returns {string} - The modified text with reduced spaces.\n */\nexport const normalizeSpaces = (text: string): string => {\n return text.replace(/[ \\t]+/g, ' ');\n};\n\n/**\n * Removes spaces inside brackets, parentheses, or square brackets.\n * Example: '( a b )' becomes '(a b)'.\n * @param {string} text - The input text with spaces inside brackets.\n * @returns {string} - The modified text with spaces removed inside brackets.\n */\nexport const removeSpaceInsideBrackets = (text: string): string => {\n return text.replace(/([\\[\\(])\\s*(.*?)\\s*([\\]\\)])/g, '$1$2$3');\n};\n\n/**\n * Removes bold styling from text by normalizing the string and removing stylistic characters.\n * @param {string} text - The input text containing bold characters.\n * @returns {string} - The modified text with bold styling removed.\n */\nexport const stripBoldStyling = (text: string): string => {\n // Normalize the string to NFKD form\n const normalizedString = text.normalize('NFKD');\n\n // Remove combining marks (diacritics) and stylistic characters from the string\n return normalizedString.replace(/[\\u0300-\\u036f]/g, '').trim();\n};\n\n/**\n * Removes italicized characters by replacing italic Unicode characters with their normal counterparts.\n * Example: '𝘼𝘽𝘾' becomes 'ABC'.\n * @param {string} text - The input text containing italicized characters.\n * @returns {string} - The modified text with italics removed.\n */\nexport const stripItalicsStyling = (text: string): string => {\n const italicMap: Record<string, string> = {\n '\\uD835\\uDC4E': 'I',\n '\\uD835\\uDC68': 'g',\n '\\u{1D63C}': '!',\n '\\uD835\\uDC4F': 'J',\n '\\uD835\\uDC69': 'h',\n '\\u{1D63D}': '?',\n '\\uD835\\uDC50': 'K',\n '\\uD835\\uDC6A': 'i',\n '\\uD835\\uDC51': 'L',\n '\\uD835\\uDC6B': 'j',\n '\\u{1D63F}': ',',\n '\\uD835\\uDC52': 'M',\n '\\uD835\\uDC6C': 'k',\n '\\u{1D640}': '.',\n '\\uD835\\uDC53': 'N',\n '\\uD835\\uDC6D': 'l',\n '\\uD835\\uDC54': 'O',\n '\\uD835\\uDC6E': 'm',\n '\\uD835\\uDC6F': 'n',\n '\\uD835\\uDC56': 'Q',\n '\\uD835\\uDC70': 'o',\n '\\uD835\\uDC57': 'R',\n '\\uD835\\uDC71': 'p',\n '\\uD835\\uDC58': 'S',\n '\\uD835\\uDC72': 'q',\n '\\uD835\\uDC59': 'T',\n '\\uD835\\uDC73': 'r',\n '\\u{1D647}': '-',\n '\\uD835\\uDC5A': 'U',\n '\\uD835\\uDC74': 's',\n '\\uD835\\uDC5B': 'V',\n '\\uD835\\uDC75': 't',\n '\\uD835\\uDC5C': 'W',\n '\\uD835\\uDC76': 'u',\n '\\uD835\\uDC5D': 'X',\n '\\uD835\\uDC77': 'v',\n '\\uD835\\uDC5E': 'Y',\n '\\uD835\\uDC78': 'w',\n '\\uD835\\uDC5F': 'Z',\n '\\uD835\\uDC79': 'x',\n '\\uD835\\uDC46': 'A',\n '\\uD835\\uDC7A': 'y',\n '\\uD835\\uDC47': 'B',\n '\\uD835\\uDC7B': 'z',\n '\\uD835\\uDC62': 'a',\n '\\uD835\\uDC48': 'C',\n '\\uD835\\uDC63': 'b',\n '\\uD835\\uDC49': 'D',\n '\\uD835\\uDC64': 'c',\n '\\uD835\\uDC4A': 'E',\n '\\uD835\\uDC65': 'd',\n '\\uD835\\uDC4B': 'F',\n '\\uD835\\uDC66': 'e',\n '\\uD835\\uDC4C': 'G',\n '\\uD835\\uDC67': 'f',\n '\\uD835\\uDC4D': 'H',\n '\\uD835\\uDC55': 'P',\n };\n\n return text.replace(/[\\uD835\\uDC62-\\uD835\\uDC7B\\uD835\\uDC46-\\uD835\\uDC5F\\u{1D63C}-\\u{1D647}]/gu, (match) => {\n return italicMap[match] || match;\n });\n};\n\n/**\n * Removes all bold and italic styling from the input text.\n * @param {string} text - The input text to remove styling from.\n * @returns {string} - The modified text with all styling removed.\n */\nexport const stripStyling = (text: string): string => {\n return stripItalicsStyling(stripBoldStyling(text));\n};\n\n/**\n * Removes unnecessary spaces inside quotes.\n * Example: '“ Text ”' becomes '“Text”'.\n * @param {string} text - The input text with spaces inside quotes.\n * @returns {string} - The modified text with spaces removed inside quotes.\n */\nexport const trimSpaceInsideQuotes = (text: string): string => {\n return text.replace(/([“”\"]|«) *(.*?) *([“”\"]|»)/g, '$1$2$3');\n};\n","/**\n * Converts a string that resembles JSON but with numeric keys and single-quoted values\n * into valid JSON format. This function replaces numeric keys with quoted numeric keys\n * and ensures all values are double-quoted as required by JSON.\n *\n * @param {string} str - The input string that needs to be fixed into valid JSON.\n * @returns {string} - A valid JSON string.\n *\n * @example\n * const result = normalizeJsonSyntax(\"{10: 'abc', 20: 'def'}\");\n * console.log(result); // '{\"10\": \"abc\", \"20\": \"def\"}'\n */\nexport const normalizeJsonSyntax = (str: string): string => {\n let input = str.replace(/(\\b\\d+\\b)(?=:)/g, '\"$1\"');\n input = input.replace(/:\\s*'([^']+)'/g, ': \"$1\"');\n input = input.replace(/:\\s*\"([^\"]+)\"/g, ': \"$1\"');\n\n return JSON.stringify(JSON.parse(input));\n};\n\n/**\n * Checks if a given string resembles a JSON object with numeric or quoted keys and values\n * that are single or double quoted. This is useful for detecting malformed JSON-like\n * structures that can be fixed by the `normalizeJsonSyntax` function.\n *\n * @param {string} str - The input string to check.\n * @returns {boolean} - Returns true if the string is JSON-like, false otherwise.\n *\n * @example\n * const result = isJsonStructureValid(\"{10: 'abc', 'key': 'value'}\");\n * console.log(result); // true\n */\nexport const isJsonStructureValid = (str: string): boolean => {\n // Checks for a pattern with numeric keys or quoted keys and values in quotes\n const jsonLikePattern =\n /^{(\\s*(\\d+|'[^']*'|\"[^\"]*\")\\s*:\\s*('|\")[^'\"]*\\3\\s*,)*(?:\\s*(\\d+|'[^']*'|\"[^\"]*\")\\s*:\\s*('|\")[^'\"]*\\5\\s*)}$/;\n return jsonLikePattern.test(str.trim());\n};\n\n/**\n * Splits a string by spaces and quoted substrings.\n *\n * This function takes an input string and splits it into parts where substrings\n * enclosed in double quotes are treated as a single part. Other substrings\n * separated by spaces are split normally.\n *\n * @param {string} query - The input string to be split.\n * @returns {string[]} An array of strings, with quoted substrings kept intact.\n *\n * @example\n * const result = splitByQuotes('\"This is\" \"a part of the\" \"string and\"');\n * console.log(result); // [\"This is\", \"a part of the\", \"string and\"]\n */\nexport const splitByQuotes = (query: string): string[] => {\n const regex = /(?:[^\\s\"]+|\"(.*?)\")+/g;\n return (query.match(regex) || []).map((s: string) => (s.startsWith('\"') ? s.slice(1, -1) : s));\n};\n","/**\n * Removes various symbols, part references, and numerical markers from the text.\n * Example: '(1) (2/3)' becomes ''.\n * @param {string} text - The input text to apply the rule to.\n * @returns {string} - The modified text with symbols and part references removed.\n */\nexport const cleanSymbolsAndPartReferences = (text: string): string => {\n return text.replace(\n / *\\(?:\\d+(?:\\/\\d+){0,2}\\)? *| *\\[\\d+(?:\\/\\d+)?\\] *| *«\\d+» *|\\d+\\/\\d+(?:\\/\\d+)?|[،§{}؍﴿﴾<>;_؟»«:!،؛\\[\\]…ـ¬\\.\\\\\\/\\*\\(\\)\"]/g,\n ' ',\n );\n};\n\n/**\n * Removes trailing page numbers formatted as '-[46]-' from the text.\n * Example: 'This is some -[46]- text' becomes 'This is some text'.\n * @param {string} text - The input text with trailing page numbers.\n * @returns {string} - The modified text with page numbers removed.\n */\nexport const cleanTrailingPageNumbers = (text: string): string => {\n return text.replace(/-\\[\\d+\\]-/g, '');\n};\n\n/**\n * Replaces consecutive line breaks and whitespace characters with a single space.\n * Example: 'a\\nb' becomes 'a b'.\n * @param {string} text - The input text containing line breaks or multiple spaces.\n * @returns {string} - The modified text with spaces.\n */\nexport const replaceLineBreaksWithSpaces = (text: string): string => {\n return text.replace(/\\s+/g, ' ');\n};\n\n/**\n * Removes all numeric digits from the text.\n * Example: 'abc123' becomes 'abc'.\n * @param {string} text - The input text containing digits.\n * @returns {string} - The modified text with digits removed.\n */\nexport const stripAllDigits = (text: string): string => {\n return text.replace(/[0-9]/g, '');\n};\n\n/**\n * Removes death year references like \"(d. 390H)\" and \"[d. 100h]\" from the text.\n * Example: 'Sufyān ibn ‘Uyaynah (d. 198h)' becomes 'Sufyān ibn ‘Uyaynah'.\n * @param {string} text - The input text containing death year references.\n * @returns {string} - The modified text with death years removed.\n */\nexport const removeDeathYear = (text: string): string => {\n return text.replace(/\\[(d)\\.\\s*\\d{1,4}[hH]\\]\\s*|\\((d)\\.\\s*\\d{1,4}[hH]\\)\\s*/g, '');\n};\n\n/**\n * Removes numeric digits and dashes from the text.\n * Example: 'ABC 123-Xyz' becomes 'ABC Xyz'.\n * @param {string} text - The input text containing digits and dashes.\n * @returns {string} - The modified text with numbers and dashes removed.\n */\nexport const removeNumbersAndDashes = (text: string): string => {\n return text.replace(/[\\d-]/g, '');\n};\n\n/**\n * Removes single digit references like (1), «2», [3] from the text.\n * Example: 'Ref (1), Ref «2», Ref [3]' becomes 'Ref , Ref , Ref '.\n * @param {string} text - The input text containing single digit references.\n * @returns {string} - The modified text with single digit references removed.\n */\nexport const removeSingleDigitReferences = (text: string): string => {\n return text.replace(/\\(\\d{1}\\)|\\[\\d{1}\\]|«\\d»/g, '');\n};\n\n/**\n * Removes URLs from the text.\n * Example: 'Visit https://example.com' becomes 'Visit '.\n * @param {string} text - The input text containing URLs.\n * @returns {string} - The modified text with URLs removed.\n */\nexport const removeUrls = (text: string): string => {\n return text.replace(\n /https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g,\n '',\n );\n};\n","import { normalizeSpaces } from './formatting';\n\n/**\n * Replaces common Arabic prefixes (like 'Al-', 'Ar-', 'Ash-', etc.) with 'al-' in the text.\n * Handles different variations of prefixes such as Ash- and Al- but not when the second word\n * does not start with 'S'.\n * Example: 'Ash-Shafiee' becomes 'al-Shafiee'.\n *\n * @param {string} text - The input text containing Arabic prefixes.\n * @returns {string} - The modified text with standardized 'al-' prefixes.\n */\nexport const normalizeArabicPrefixesToAl = (text: string): string => {\n return text\n .replace(/(\\b|\\W)(Al |Al-|Ar-|As-|Adh-|Ad-|Ats-|Ath |Ath-|Az |Az-|az-|adh-|as-|ar-)/g, '$1al-')\n .replace(/(\\b|\\W)(Ash-S|ash-S)/g, '$1al-S')\n .replace(/al- (.+?)\\b/g, 'al-$1');\n};\n\n/**\n * Removes double occurrences of Arabic apostrophes such as ʿʿ or ʾʾ in the text.\n * Example: 'ʿulamāʾʾ' becomes 'ʿulamāʾ'.\n *\n * @param {string} text - The input text containing double apostrophes.\n * @returns {string} - The modified text with condensed apostrophes.\n */\nexport const normalizeDoubleApostrophes = (text: string): string => {\n return text.replace(/ʿʿ/g, 'ʿ').replace(/ʾʾ/g, 'ʾ');\n};\n\n/**\n * Replaces common salutations such as \"sallahu alayhi wasallam\" with \"ﷺ\" in the text.\n * It also handles variations of the salutation phrase, including 'peace and blessings be upon him'.\n * Example: 'Then Muḥammad (sallahu alayhi wasallam)' becomes 'Then Muḥammad ﷺ'.\n *\n * @param {string} text - The input text containing salutations.\n * @returns {string} - The modified text with salutations replaced.\n */\nexport const replaceSalutationsWithSymbol = (text: string): string => {\n return text\n .replace(\n /\\(peace be upon him\\)|(Messenger of (Allah|Allāh)|Messenger|Prophet|Mu[hḥ]ammad) *\\((s[^)]*m|peace[^)]*him|May[^)]*him|may[^)]*him)\\)*/gi,\n '$1 ﷺ',\n )\n .replace(/,\\s*ﷺ\\s*,/g, ' ﷺ');\n};\n\n/**\n * Normalizes the text by removing diacritics, apostrophes, and dashes.\n * Example: 'Al-Jadwal' becomes 'AlJadwal'.\n *\n * @param {string} input - The input text to normalize.\n * @returns {string} - The normalized text.\n */\nexport const normalize = (input: string) => {\n return input\n .normalize('NFKD')\n .replace(/[\\u0300-\\u036f]/g, '')\n .replace(/`|ʾ|ʿ|-/g, '');\n};\n\n/**\n * Replaces various apostrophe characters (‛, ’, ‘) with the standard apostrophe (').\n * Example: '‛ulama’ al-su‘' becomes ''ulama' al-su''.\n *\n * @param {string} text - The input text containing different apostrophe characters.\n * @returns {string} - The modified text with normalized apostrophes.\n */\nexport const normalizeApostrophes = (text: string): string => {\n return text.replace(/‛|’|‘/g, \"'\");\n};\n\n/**\n * Strips common Arabic prefixes like 'al-', 'bi-', 'fī', 'wa-', etc. from the beginning of words.\n * Example: 'al-Bukhari' becomes 'Bukhari'.\n *\n * @param {string} text - The input text containing Arabic prefixes.\n * @returns {string} - The modified text with prefixes stripped.\n */\nexport const removeArabicPrefixes = (text: string): string => {\n return normalizeSpaces(text.replace(/(\\bal-|\\bli-|\\bbi-|\\bfī|\\bwa[-\\s]+|\\bl-|\\bliʿl|\\Bʿalá|\\Bʿan|\\bb\\.)/gi, ''));\n};\n\n/**\n * Simplifies English transliterations by removing diacritics, apostrophes, and common prefixes.\n * Example: 'Al-Jadwal' becomes 'Jadwal', and 'āḍġḥīṣṭū' becomes 'adghistu'.\n *\n * @param {string} text - The input text to simplify.\n * @returns {string} - The simplified text.\n */\nexport const normalizeTransliteratedEnglish = (text: string): string => normalize(removeArabicPrefixes(text));\n\n/**\n * Extracts the initials from the input string, typically used for names or titles.\n * Example: 'Nayl al-Awtar' becomes 'NA'.\n *\n * @param {string} text - The input text to extract initials from.\n * @returns {string} - The extracted initials.\n */\nexport const extractInitials = (fullName: string) => {\n const initials = normalizeTransliteratedEnglish(fullName)\n .trim()\n .split(/[ -]/)\n .slice(0, 2)\n .map((word) => {\n return word.charAt(0).toUpperCase();\n })\n .join('');\n return initials;\n};\n"],"names":[],"version":3,"file":"main.js.map","sourceRoot":"../"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bitaboom",
|
|
3
3
|
"description": "Use string utils library to format Arabic and English translations.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"author": "Ragaeeb Haq",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"private": false,
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"url": "git+https://github.com/ragaeeb/bitaboom.git"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
17
|
+
"node": ">=23.0.0"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"dist/main.js",
|
|
@@ -30,28 +30,24 @@
|
|
|
30
30
|
"arabic"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@eslint/js": "^9.
|
|
34
|
-
"@parcel/packager-ts": "^2.
|
|
35
|
-
"@parcel/transformer-typescript-types": "^2.
|
|
36
|
-
"@semantic-release/changelog": "^6.0.3",
|
|
33
|
+
"@eslint/js": "^9.24.0",
|
|
34
|
+
"@parcel/packager-ts": "^2.14.4",
|
|
35
|
+
"@parcel/transformer-typescript-types": "^2.14.4",
|
|
37
36
|
"@semantic-release/git": "^10.0.1",
|
|
38
|
-
"@types/
|
|
39
|
-
"@
|
|
40
|
-
"
|
|
41
|
-
"eslint": "^
|
|
42
|
-
"eslint-
|
|
43
|
-
"eslint-plugin-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"parcel": "^2.12.0",
|
|
49
|
-
"prettier": "^3.3.3",
|
|
50
|
-
"semantic-release": "^24.1.1",
|
|
37
|
+
"@types/node": "^22.14.1",
|
|
38
|
+
"@vitest/coverage-v8": "^3.1.1",
|
|
39
|
+
"eslint": "^9.24.0",
|
|
40
|
+
"eslint-config-prettier": "^10.1.2",
|
|
41
|
+
"eslint-plugin-perfectionist": "^4.11.0",
|
|
42
|
+
"eslint-plugin-prettier": "^5.2.6",
|
|
43
|
+
"globals": "^16.0.0",
|
|
44
|
+
"parcel": "^2.14.4",
|
|
45
|
+
"prettier": "^3.5.3",
|
|
46
|
+
"semantic-release": "^24.2.3",
|
|
51
47
|
"ts-node": "^10.9.2",
|
|
52
|
-
"typescript": "^5.
|
|
53
|
-
"typescript-eslint": "^8.
|
|
54
|
-
"vitest": "^
|
|
48
|
+
"typescript": "^5.8.3",
|
|
49
|
+
"typescript-eslint": "^8.30.1",
|
|
50
|
+
"vitest": "^3.1.1"
|
|
55
51
|
},
|
|
56
|
-
"packageManager": "pnpm@
|
|
52
|
+
"packageManager": "pnpm@10.8.1+sha512.c50088ba998c67b8ca8c99df8a5e02fd2ae2e2b29aaf238feaa9e124248d3f48f9fb6db2424949ff901cffbb5e0f0cc1ad6aedb602cd29450751d11c35023677"
|
|
57
53
|
}
|