194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
[/^(qu|lorsqu|puisqu|quoiqu|presqu|jusqu|aujourd|entr|quelqu|prud) /ig, "$1’"] ],
"ma_1letter_lowercase": [ [/[ ]([ldjnmtscç]) (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])/g, "$1’"] ],
"ma_1letter_uppercase": [ [/[ ]([LDJNMTSCÇ]) (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])/g, "$1’"],
[/^([LDJNMTSCÇ]) (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])/g, "$1’"] ]
};
const dDefaultOptions = new Map ([
["ts_units", true],
["start_of_paragraph", true],
["end_of_paragraph", true],
["between_words", true],
["before_punctuation", true],
["within_parenthesis", true],
["within_square_brackets", true],
|
|
|
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
[/^(qu|lorsqu|puisqu|quoiqu|presqu|jusqu|aujourd|entr|quelqu|prud) /ig, "$1’"] ],
"ma_1letter_lowercase": [ [/[ ]([ldjnmtscç]) (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])/g, "$1’"] ],
"ma_1letter_uppercase": [ [/[ ]([LDJNMTSCÇ]) (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])/g, "$1’"],
[/^([LDJNMTSCÇ]) (?=[aàeéêiîoôuyhAÀEÉÊIÎOÔUYH])/g, "$1’"] ]
};
const dTFDefaultOptions = new Map ([
["ts_units", true],
["start_of_paragraph", true],
["end_of_paragraph", true],
["between_words", true],
["before_punctuation", true],
["within_parenthesis", true],
["within_square_brackets", true],
|
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
["etc", true],
["missing_hyphens", true],
["ma_word", true],
["ma_1letter_lowercase", false],
["ma_1letter_uppercase", false]
]);
const dOptions = dDefaultOptions.gl_shallowCopy();
class TextFormatter {
constructor () {
this.sLang = "fr";
};
formatText (sText, dOpt=null) {
if (dOpt !== null) {
dOptions.gl_updateOnlyExistingKeys(dOpt);
}
for (let [sOptName, bVal] of dOptions) {
if (bVal && oReplTable.has(sOptName)) {
for (let [zRgx, sRep] of oReplTable[sOptName]) {
sText = sText.replace(zRgx, sRep);
}
}
}
return sText;
};
getDefaultOptions () {
return dDefaultOptions;
}
}
if (typeof(exports) !== 'undefined') {
exports.TextFormatter = TextFormatter;
exports.oReplTable = oReplTable;
}
|
|
|
|
|
|
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
["etc", true],
["missing_hyphens", true],
["ma_word", true],
["ma_1letter_lowercase", false],
["ma_1letter_uppercase", false]
]);
const dTFOptions = dTFDefaultOptions.gl_shallowCopy();
class TextFormatter {
constructor () {
this.sLang = "fr";
};
formatText (sText, dOpt=null) {
if (dOpt !== null) {
dTFOptions.gl_updateOnlyExistingKeys(dOpt);
}
for (let [sOptName, bVal] of dTFOptions) {
if (bVal && oReplTable.has(sOptName)) {
for (let [zRgx, sRep] of oReplTable[sOptName]) {
sText = sText.replace(zRgx, sRep);
}
}
}
return sText;
};
getDefaultOptions () {
return dTFDefaultOptions;
}
}
if (typeof(exports) !== 'undefined') {
exports.TextFormatter = TextFormatter;
exports.oReplTable = oReplTable;
}
|