320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
sText = sText.replace(zRgx, sRep);
}
} else if (this.bDebug){
console.log("# Error. TF: there is no option “" + sRuleName+ "”.");
}
return [sText, nCount];
}
getDefaultOptions () {
//we return a copy to make sure they are no modification in external
return dTFDefaultOptions.gl_shallowCopy();
}
getUsedOptions () {
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
sText = sText.replace(zRgx, sRep);
}
} else if (this.bDebug){
console.log("# Error. TF: there is no option “" + sRuleName+ "”.");
}
return [sText, nCount];
}
removeHyphenAtEndOfParagraphs (sText) {
sText = sText.replace(/-[ ]*\n/gm, "");
return sText;
}
removeHyphenAtEndOfParagraphsCount (sText) {
let nCount = (sText.match(/-[ ]*\n/gm) || []).length;
sText = sText.replace(/-[ ]*\n/gm, "");
return [sText, nCount];
}
mergeContiguousParagraphs (sText) {
sText = sText.replace(/^[ ]+$/gm, ""); // clear empty paragraphs
let s = "";
for (let sParagraph of this.getParagraph(sText)) {
if (sParagraph === "") {
s += "\n";
} else {
s += sParagraph + " ";
}
}
s = s.replace(/ +/gm, " ").replace(/ $/gm, "");
return s;
}
mergeContiguousParagraphsCount (sText) {
let nCount = 0;
sText = sText.replace(/^[ ]+$/gm, ""); // clear empty paragraphs
let s = "";
for (let sParagraph of this.getParagraph(sText)) {
if (sParagraph === "") {
s += "\n";
} else {
s += sParagraph + " ";
nCount += 1;
}
}
s = s.replace(/ +/gm, " ").replace(/ $/gm, "");
return [s, nCount];
}
* getParagraph (sText, sSep="\n") {
// generator: returns paragraphs of text
let iStart = 0;
let iEnd = 0;
while ((iEnd = sText.indexOf(sSep, iStart)) !== -1) {
yield sText.slice(iStart, iEnd);
iStart = iEnd + 1;
}
yield sText.slice(iStart);
}
getDefaultOptions () {
//we return a copy to make sure they are no modification in external
return dTFDefaultOptions.gl_shallowCopy();
}
getUsedOptions () {
|