twl-generator 1.4.2 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "twl-generator",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Generate term-to-article lists from unfoldingWord en_tw archive for Bible books. Works in both Node.js (CLI) and React.js (browser) environments.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -60,4 +60,4 @@
|
|
|
60
60
|
"optional": true
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
}
|
|
63
|
+
}
|
package/src/utils/twl-matcher.js
CHANGED
|
@@ -162,23 +162,9 @@ class PrefixTrie {
|
|
|
162
162
|
// Always extract from the original text to preserve case
|
|
163
163
|
let originalMatchedText = originalText.substring(startPos, currentPos);
|
|
164
164
|
|
|
165
|
-
// Extend match backwards to include dash-connected words
|
|
165
|
+
// Extend match backwards to include possessive forms (but not dash-connected words)
|
|
166
166
|
let extendedStartPos = startPos;
|
|
167
167
|
|
|
168
|
-
// Check backwards for dash preceded by word characters (no space between)
|
|
169
|
-
if (extendedStartPos > 0 && originalText[extendedStartPos - 1] === '-') {
|
|
170
|
-
let dashPos = extendedStartPos - 1;
|
|
171
|
-
dashPos--; // Move before the dash
|
|
172
|
-
// Check if there are word characters immediately before the dash
|
|
173
|
-
if (dashPos >= 0 && /[\w]/.test(originalText[dashPos])) {
|
|
174
|
-
// Find the start of the word before the dash
|
|
175
|
-
while (dashPos >= 0 && /[\w]/.test(originalText[dashPos])) {
|
|
176
|
-
dashPos--;
|
|
177
|
-
}
|
|
178
|
-
extendedStartPos = dashPos + 1;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
168
|
// Check backwards for apostrophe (straight or curly) preceded by text
|
|
183
169
|
if (extendedStartPos > 0 && /['']/.test(originalText[extendedStartPos - 1])) {
|
|
184
170
|
let apostrophePos = extendedStartPos - 1;
|
|
@@ -193,23 +179,9 @@ class PrefixTrie {
|
|
|
193
179
|
}
|
|
194
180
|
}
|
|
195
181
|
|
|
196
|
-
// Extend match forwards to include dash-connected words
|
|
182
|
+
// Extend match forwards to include possessive forms (but not dash-connected words)
|
|
197
183
|
let extendedEndPos = currentPos;
|
|
198
184
|
|
|
199
|
-
// Check for dash followed by word characters (no space between)
|
|
200
|
-
if (extendedEndPos < originalText.length && originalText[extendedEndPos] === '-') {
|
|
201
|
-
let dashPos = extendedEndPos;
|
|
202
|
-
dashPos++; // Move past the dash
|
|
203
|
-
// Check if there are word characters immediately after the dash
|
|
204
|
-
if (dashPos < originalText.length && /[\w]/.test(originalText[dashPos])) {
|
|
205
|
-
// Find the end of the word after the dash
|
|
206
|
-
while (dashPos < originalText.length && /[\w]/.test(originalText[dashPos])) {
|
|
207
|
-
dashPos++;
|
|
208
|
-
}
|
|
209
|
-
extendedEndPos = dashPos;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
185
|
// Check for apostrophe (straight or curly) followed by text
|
|
214
186
|
if (extendedEndPos < originalText.length && /['']/.test(originalText[extendedEndPos])) {
|
|
215
187
|
let apostrophePos = extendedEndPos;
|
|
@@ -38,7 +38,7 @@ async function processZipBuffer(zipBuffer) {
|
|
|
38
38
|
const content = await entry.getData(); // Await the async string content
|
|
39
39
|
const firstLine = content.split('\n')[0];
|
|
40
40
|
const terms = firstLine.replace(/^#/, '').trim().split(',').map(t => t.trim()).filter(Boolean);
|
|
41
|
-
const truncated = entry.entryName.replace('en_tw/bible/', '');
|
|
41
|
+
const truncated = entry.entryName.replace('en_tw/bible/', '').replace(/\.md$/, '');
|
|
42
42
|
|
|
43
43
|
for (const term of terms) {
|
|
44
44
|
// Normalize terms by removing parentheses and spaces before them
|