import { SourceType } from "../config";
function pointedCharacters2Epidoc(text: string): string {
// var text = text.replace(/([aA-zZ])\x{323}/g, '$1'); //a
//text = text.replace(/\u1E5B\/u/g, 'r'); //r
/* console.log("Texte dot ---:" + text);*/
return text;
};
/**
* Convert an input text using different variants of the Leiden conventions.
* Adopted from the [Ausohnum Library](https://gitlab.huma-num.fr/estudium/ausohnum-library/-/blob/master/resources/scripts/teiEditor/ancientTextImportRules.js).
*
* @param text content to convert
* @param importSource the type of the input
* @returns resulting epiDoc XML
*/
export function ancientText2XML(text: string, importSource: SourceType): string {
const textImportMode = 'newText';
const startingLineNumber = 1;
//Clean tabs
text = text.toString().replace(/\t+/g, '')
///r to /n
text = text.replace(/\r/g, '');
if (text.toString().length - text.toString().lastIndexOf(" ") == 1) {
text = text.toString().substring(0, text.toString().lastIndexOf(" "));
}
//First Line
if (textImportMode === "newText") {
text = '
' + text;
/*
*****************************
* Line breaks *
*****************************/
//New lines no word break
const regexLine = /(\-|-?|\=?)\s?\n/g;
let index = startingLineNumber - 1;
text = text.replace(regexLine, function (match, selection) {
if ((selection === "-") || (selection === "=")) {
return '\n
';
} else {
return '\n
';
}
});
//All line in lacuna [— — — — — — — — — — —]
text = text.replace(/(\)\[(\s?—\s?){3,50}\]\n(\)/g, '$1\n$3');
if (importSource == SourceType.edcs) {
index = 0;
text = text.replace(/(\s)?(\/\/)(?!\>)(\s)?/g, function (match) {
if (match[0] === "/") { var breakNo = ' break="no"' }
else { var breakNo = "" };
return '\n';
});
//Line breaks
const regexLine = /(\s)?(\/{1})(?!\>)(\s)?/g;
index = 0;
text = text.replace(regexLine, function (match) {
if (match[0] === "/") { var breakNo = ' break="no"' }
else { var breakNo = "" };
console.log("BreakNo = " + breakNo);
console.log("Match 0= " + match[0]);
return '\n
';
});
};
if (importSource == SourceType.phi) {
text = text.replace(/#⁷/g, '');
text = text.replace(/#⁷#⁷#⁷/g, '');
text = text.replace(/#⁵⁶/g, '▴');
}; //End of features specific to PHI
//Lines 5, 10, 15, etc.
const regexLines5 = /\n\1\s/g;
const substLines5 = '\n
';
text = text.replace(regexLines5, substLines5);
/* Removing original line number*/
const regexLineClean = /(\"[0-9]{1,3}\"\/>)([0-9]{1,3})/g;
const substLineClean = "$1";
text = text.replace(regexLineClean, substLineClean);
}; //End of line breaks if insertMode is newText
/*
*****************************
* Corrections *
*****************************/
const regexCorrection = /\<([^\x00-\x7F]*[aA-zZ]*)(?!\=)(?!\/)\>/g;
const substCorrection = '$1';
text = text.replace(regexCorrection, substCorrection);
const regexCorrectionOther = /⟨([^\x00-\x7F]*[aA-zZ]*)(?!\=)(?!\/)⟩/g;
const substCorrectionOther = '$1';
text = text.replace(regexCorrectionOther, substCorrectionOther);
/****************************/
/* EDCS */
/******************************/
if (importSource == SourceType.edcs) {
/* console.log("in EDCS2 for " + text);*/
const regexCorrection2EDCS = /\<([^\x00-\x7F]*[aA-zZ]*)(\=)([^\x00-\x7F]*[aA-zZ]*)(?!\/)\>/g;
const substCorrection2EDCS = ""
+ "$1"
+ "$3"
text = text.replace(regexCorrection2EDCS, substCorrection2EDCS);
/* Line in lacuna [6]*/
text = text.replace(/\[6\]/g,
'');
text = text.replace(/\[3\]/g,
'');
text = text.replace(/\[3\s([^\x00-\x7F]*[aA-zZ]*)\]/g,
''
+ '$1');
text = text.replace(/\[3\s/g,
''
+ '');
text = text.replace(/\s3\s/g,
' - - - '
);
text = text.replace(/\s3\]/g,
' - - -]'
);
text = text.replace(/a\(\)/g, 'a');
};
/* End of EDCS-specific features*/
/* (!), (sic)...*/
text = text.replace(/\(\!\)/g, '!');
text = text.replace(/\(sic\)/g, 'sic');
//Lacunae [.....10.....]
//[– – –]
let regex = /\[(\–|\-)\s?(\–|\-)\s?(\–|\-)\]/g
text = text.replace(regex, function (match, selection) {
return '';
});
//Lacunae with precise number of letters [...6...]
regex = /\[(?:(?:\s?\.\s?){1,99})([1-9][0-9]*)(?:(?:\s?\.\s?){1,99})\]/g
text = text.replace(regex, function (match, selection) {
return '';
});
//Lacunae with precise number of letters [...6...SPACEtext
regex = /\[(?:(?:\s?\.\s?){1,99})([1-9][0-9]*)(?:(?:\s?\.\s?){1,99})\s/g
text = text.replace(regex, function (match, selection) {
const length = match.length - 2;
return '';
});
//Lacunae with precise number of letters textSPACE...6...]
regex = /\s(?:(?:\s?\.\s?){1,99})([1-9][0-9]*)(?:(?:\s?\.\s?){1,99})\]/g
text = text.replace(regex, function (match, selection) {
const length = match.length - 2;
return '';
});
//Lacunae with precise number of letters textSPACE...SPACEtext
regex = /\s(?:(?:\s?\.\s?){1,99})([1-9][0-9]*)(?:(?:\s?\.\s?){1,99})\s/g
text = text.replace(regex, function (match, selection) {
const length = match.length - 2;
return '';
});
//Lacunae with precise number of letters [....]
regex = /\[((\.){1,99})\]/g
text = text.replace(regex, function (match, selection) {
const length = match.length - 2;
return '';
});
//Lacunae with precise number of letters [...SPACEtext
regex = /\[((\.){1,99})\s/g
text = text.replace(regex, function (match, selection) {
const length = match.length - 2;
return '';
});
//Lacunae with precise number of letters textSPACE...]
regex = /\s((\.){1,99})\]/g
text = text.replace(regex, function (match, selection) {
const length = match.length - 2;
return '';
});
//Lacunae with precise number of letters textSPACE...SPACEtext
regex = /\s((\.){1,99})\s/g
text = text.replace(regex, function (match, selection) {
const length = match.length - 2;
return '';
});
//[ca. 5-7]
text = text.replace(/\[(-|–|\.\s?){1,20}ca\.(\s?)([1-9][0-9]*)((-)([1-9][0-9]*))(\s?)(-|–|\.\s?){1,20}\]/g,
'');
//[ca. 5]
text = text.replace(/\[(-|–|\.\s?){1,20}ca\.(\s?)([1-9][0-9]*)(\s?)(-|–|\.\s?){1,20}\]/g,
'');
//[...c.5-7...]
text = text.replace(
/\[(?:[\.․]){1,20}c(?:a?)\.(?:\s?)([1-9][0-9]*)(?:(?:-)([1-9][0-9]*))(?:\s?)(?:[\.․]){1,20}(?:\s?)\]/g,
'');
//[...c.5...]
text = text.replace(
/\[(?:[\.․]){1,20}c(?:a?)\.(?:\s?)([1-9][0-9]*)(?:\s?)(?:[\.․]){1,20}(?:\s?)\]/g,
'');
//[...c.5-7...
text = text.replace(
/\[(?:[\.․]){1,20}c(?:a?)\.(?:\s?)([1-9][0-9]*)(?:(?:-)([1-9][0-9]*))(?:\s?)(?:[\.․]){1,20}(?:\s)/g,
'');
//[...c.5...
text = text.replace(
/\[(?:[\.․]){1,20}c(?:a?)\.(?:\s?)([1-9][0-9]*)(?:\s?)(?:[\.․]){1,20}(?:\s)/g,
'');
//[text ...c.5-7...]
text = text.replace(
/\s(?:[\.․]){1,20}c(?:a?)\.(?:\s?)([1-9][0-9]*)(?:(?:-)([1-9][0-9]*))(?:\s?)(?:[\.․]){1,20}(?:\s?)\]/g,
'');
//[text ...c.5...]
text = text.replace(
/\s(?:[\.․]){1,20}c(?:a?)\.(?:\s?)([1-9][0-9]*)(?:\s?)(?:[\.․]){1,20}(?:\s?)\]/g,
'');
//...c.5-7...
text = text.replace(
/\s(?:[\.․]){2,20}c(?:a?)\.(?:\s?)([1-9][0-9]*)(?:(?:-)([1-9][0-9]*))(?:\s?)(?:[\.․]){1,20}(?:\s)/g,
'');
//...c.5...
text = text.replace(
/\s(?:[\.․]){2,20}c(?:a?)\.(?:\s?)([1-9][0-9]*)(?:\s?)(?:[\.․]){1,20}(?:\s)/g,
'');
//Symbol (centurio)
text = text.replace(/(?:\s|\n)\(([^\x00-\x7F]*[aA-zZ]*)\)/g,
' $1');
//Replacing double [[ with ⟦
text = text.replace(/\[{2}/g, '⟦');
//Replacing double ]] with ⟧
text = text.replace(/\]{2}/g, '⟧');
/* Abbreviation with [] [Q]ui(ina) */
text = text.replace(/\[([^\x00-\x7F]*[aA-zZ]*[^\]])\]([^\x00-\x7F]*[aA-zZ]*[^\]])\(([^\x00-\x7F]*?[aA-zZ]*?)\)/g,
'$1$2$3');
/* Abbreviation with Rasura [Q]ui(ina) */
text = text.replace(/(〚|⟦|\[\[)([^\x00-\x7F]*[aA-zZ]*[^\]])(〛|⟧|]])([^\x00-\x7F]*[aA-zZ]*[^\]])\(([^\x00-\x7F]*?[aA-zZ]*?)\)/g,
'$1$2$3');
/* Hermes [Augusti - - - lib(ertus)] ==> straitgh supplied with a gap inside (supplied not starting or ending in abbreviation */
text = text.replace(/\[(\w*?\s?)(?:(?:(?:\-|\–|\—)\s?){1,20})(\w*?)\](?![^\x00-\x7F]*?[aA-zZ]*?\()/g,
'$1$2');
//CLEANING \s?
text = text.replace(/<\/supplied>/g, '');
/* Hermes [Augusti - - - lib(ertus)] ==> straitgh RASURA with a gap inside (supplied not starting or ending in abbreviation */
text = text.replace(/(?:⟦|〚)(.*?\s?)(?:(?:(?:\-|\–|\—)\s?){1,20})(.*?)(?:⟧|〛)(?![^\x00-\x7F]*?[aA-zZ]*?\()/g,
'$1$2');
//Supplied: BLANK[szs szsz sszss(f) sss]CARRIAGE : if [] are preceded and followed by space, means can be replaced by
text = text.replace(/(?:\s)\[(.*?)\](?:\n)/g, ' $1\n');
//Supplied: BLANK[szs szsz s sss]BLANK : if [] are preceded and followed by space, means can be replaced by
text = text.replace(/(?:\s)\[(.*)\](?:\s)/g, ' $1 ');
//DEL: BLANK[szs szsz sszss(f) sss]CARRIAGE : if [] are preceded and followed by space, means can be replaced by
text = text.replace(/(?:\s)(?:⟦|〚)(.*?)(?:⟧|〛)(?:\n)/g, ' $1\n');
//DEL: BLANK[szs szsz s sss]BLANK : if [] are preceded and followed by space, means can be replaced by
text = text.replace(/(?:\s)(?:⟦|〚)(.*?)(?:⟧|〛)(?:\s)/g, ' $1 ');
/*//Supplied: BLANK[szs szsz sszss(f) sss]BLANK : if [] are preceded and followed by space, means can be replaced by
text = text.replace(/(?:\s)\[(.*?)\](?!(.*?))(?:\s)/g, ' $1 ');
*/
/*Abbreviation partly in lacuna without text after )*/
regex = /([^\x00-\x7F]*[aA-zZ]*)\[([^\x00-\x7F]*[aA-zZ]*)\(([^\x00-\x7F]*[aA-zZ]*)\)(\])/g;
let subst = '$1$2$3'
text = text.replace(regex, subst);
/*Abbreviation partly in RASURA without text after )*/
regex = /([^\x00-\x7F]*[aA-zZ]*)(?:⟦|〚)([^\x00-\x7F]*[aA-zZ]*)\(([^\x00-\x7F]*[aA-zZ]*)\)(?:⟧|〛)/g;
subst = '$1$2$3'
text = text.replace(regex, subst);
/* SUPPLIED: Au[g(usti) followed by words even ABBREV but ] not in inside an abbreviation */
text = text.replace(/([^\x00-\x7F]*?[aA-zZ]*?[^>])?\[([^\x00-\x7F]*?[aA-zZ]*?)\(([^\x00-\x7F]*?[aA-zZ]*?)\)(.*?[^\-\–\—])\](?![^\x00-\x7F]*?[aA-zZ]*\()/g,
'$1$2$3 $4');
/* Before Chnage on 7/4/20 10:38: text = text.replace(/([^\x00-\x7F]*?[aA-zZ]*?[^\s][^>])?\[([^\x00-\x7F]*?[aA-zZ]*?)\(([^\x00-\x7F]*?[aA-zZ]*?)\)(.*?[^\-\–\—])\](?![^\x00-\x7F]*?[aA-zZ]*\()/g,*/
/* text = text.replace(/([^\x00-\x7F]*?[aA-zZ]*?[^\s][^>])?(?:\s)(?:⟦|〚)([^\x00-\x7F]*?[aA-zZ]*?)\(([^\x00-\x7F]*?[aA-zZ]*?)\)(.*?[^\-\–\—])(?:⟧|〛)(?![^\x00-\x7F]*?[aA-zZ]*\()/g,*/
/* DEL: Au[[g(usti) followed by words even ABBREV but ]] not in inside an abbreviation */
text = text.replace(/([^\x00-\x7F]*?[aA-zZ]*?[^\s][^>])?(?:\s?)(?:⟦|〚)([^\x00-\x7F]*?[aA-zZ]*?)\(([^\x00-\x7F]*?[aA-zZ]*?)\)(.*?[^\-\–\—])(?:⟧|〛)(?![^\x00-\x7F]*?[aA-zZ]*\()/g,
'$1$2$3 $4');
/* SUPPLIED: Hermes Au[g(usti) libertus pr]oc(urator) [ starting and ending in a abbreviation*/
text = text.replace(/([^\x00-\x7F]*?[aA-zZ]+)\[([^\x00-\x7F]*?[aA-zZ]*?)\(([^\x00-\x7F]*?[aA-zZ]*?)\)(.*?[^\-\–\—])([^\x00-\x7F]*?[aA-zZ]*?)\](?:([^\x00-\x7F]*?[aA-zZ]*?)\(([^\x00-\x7F]*?[aA-zZ]*?)\))/g,
'$1$2$3 $4$5$6$7');
/* DEL: Hermes Au[[g(usti) libertus pr]]oc(urator) [ starting and ending in a abbreviation*/
text = text.replace(/([^\x00-\x7F]*?[aA-zZ]*?)(?:⟦|〚)([^\x00-\x7F]*?[aA-zZ]*?)\(([^\x00-\x7F]*?[aA-zZ]*?)\)(.*?[^\-\–\—])([^\x00-\x7F]*?[aA-zZ]*?)(?:⟧|〛)(?:([^\x00-\x7F]*?[aA-zZ]*?)\(([^\x00-\x7F]*?[aA-zZ]*?)\))/g,
'$1$2$3 $4$5$6$7');
// ․․․c.5-7․․․
text = text.replace(/ (?:[\.․]){1,20}c(?:a?)\.(?:\s?)([1-9][0-9]*)(?:(?:-)([1-9][0-9]*))(?:\s?)(?:[\.․]){1,20} <\/supplied>/g,
'');
//Cleaning
text = text.replace(/()<\/supplied>/g,
'$1');
//Supplied: [szs szsz sszss(f) sss]
text = text.replace(/\[(.[^\[\-\–\—]*)\](?![^\x00-\x7F]*[aA-zZ]*\()/g, '$1');
//DEL: [[]szs szsz sszss(f) sss]]
text = text.replace(/(?:⟦|〚)(.[^\[]*)\](?![^\x00-\x7F]*[aA-zZ]*\()/g, '$1');
/*
* THIS regex is making everything slow
/\* SUPPLIED: Herm[es Aug(usti) libertus pr]oc(urator) ending in a abbreviation*\/
text = text.replace(/(?:([^\x00-\x7F]*?[aA-zZ]*?[^\s])*)\[([^\x00-\x7F]*?[aA-zZ]*?)\s(.*?)([^\x00-\x7F]*?[aA-zZ]*?)\](?:([^\x00-\x7F]*?[aA-zZ]*?)\(([^\x00-\x7F]*?[aA-zZ]*?)\))/g,
'$1$3 $4$5$6$7');
*/
/* SUPPLIED: [Aug(usti) */
text = text.replace(/(?:\s)\[((.[^\.<])*)\s/g,
' $1$2');
/*Was before: text = text.replace(/(?:\s)\[([^\x00-\x7F]*[aA-zZ]*)\(([^\x00-\x7F]*[aA-zZ]*)\)/g,*/
/* SUPPLIED ddd(t)] */
text = text.replace(/(?!([^\x00-\x7F]*[aA-zZ]*))(\s)([^\x00-\x7F]*[aA-zZ]*)\(([^\x00-\x7F]*[aA-zZ]*)\)\]/g,
'$1$2$3');
/* SUPPLIED dd]d(t) */
text = text.replace(/(\s)([^\x00-\x7F]*?[aA-zZ]*?)\]([^\x00-\x7F]*?[aA-zZ]*?)\(([^\x00-\x7F]*[aA-zZ]*)\)/g,
'$1$2$3$4');
/* SUPPLIED: A[ug(usti) */
text = text.replace(/(\s)([^\x00-\x7F]+[aA-zZ]+)\[([^\x00-\x7F]*[aA-zZ]*)\(([^\x00-\x7F]*[aA-zZ]*)\)/g,
' $2$3$4 ');
//SUPPLIED: xx[frfrfrf(?) - - - - - - ]
text = text.replace(/\[([^\x00-\x7F]*[aA-zZ]*)\(\?\)((\s?(\-|\–|\—)\s?){1,20})\]/g,
'$1');
//SUPPLIED: xx[frfrfrf - - - - - - frf]
text = text.replace(/\[([^\x00-\x7F]*[aA-zZ]*)((\s?(\-|\–|\—)\s?){1,20})\]/g,
'$1');
/*
*****************************
* Abbreviations *
*****************************/
/*Word with multiple abbreviations*/
/* var regex= /\[(․{1,20})\]/g;
index =0;
text = text.replace(regex, function(match){
console.log('Ici match:' + match.length );
var length = parseInt(match.length) -2;
return '' ;
});
*/
/*Abbreviation partly in lacuna with text after )*/
regex = /([^\x00-\x7F]*[aA-zZ]*)\[([^\x00-\x7F]*[aA-zZ]*)\(([^\x00-\x7F]*[aA-zZ]*)\)(\s)?([^\x00-\x7F]*[aA-zZ]*)?(\s)?(\])/g;
subst = '$1$2$3$4$5'
text = text.replace(regex, subst);
/* Abbreviation in Rasura*/
regex = /(〚|⟦|\[\[)([^\x00-\x7F]*[aA-zZ]*)\(([^\x00-\x7F]*[aA-zZ]*)\)([^\x00-\x7F]*[aA-zZ]*)?(〛|⟧|]])/g;
subst = '$2$3$4';
text = text.replace(regex, subst);
/* Abbreviation in Lacuna*/
regex = /\[([^\x00-\x7F]*[aA-zZ]*)\(([^\x00-\x7F]*[aA-zZ]*)\)(])/g;
subst = '$1$2';
text = text.replace(regex, subst);
/* Abbreviation with uncertain resolution*/
regex = /([^\x00-\x7F]*[aA-zZ]*)\(([^\x00-\x7F]*[aA-zZ]*)\?\)/g;
const substAbbrevInLac = '$1$2';
text = text.replace(regex, substAbbrevInLac);
/*Double abbreviation*/
regex = /([^\x00-\x7F]*[aA-zZ]*)\(([^\x00-\x7F]*[aA-zZ]*)\)([^\x00-\x7F]*[aA-zZ]*)*\(([^\x00-\x7F]*[aA-zZ]*)\)/g;
subst = "$1$2$3$4";
text = text.replace(regex, subst);
/*Basic abbreviation*/
regex = /([^\x00-\x7F]*[aA-zZ]*)\(([^\x00-\x7F]*[aA-zZ]*)\)([^\x00-\x7F]*[aA-zZ]*)*/g;
subst = "$1$2$3";
text = text.replace(regex, subst);
//cleaning wrong closing of expan
text = text.replace("\<\/expan\>\\", "");
/*
*****************************
* Line in lacuna *
*****************************/
//Line in lacuna [------]
text = text.replace('\n\[------\]', '');
//Line in lacuna ------
text = text.replace(/(-){6}/g, '');
/*//All line [— — — — — — — — — — —
text = text.replace(/(\)\[(—\s?)*\]/g, '$1');
*/
//text = text.replace(/(\)\[(\s?—\s?)*\]/g, '$1\n');
//Part of line [— — — — — — — — — — —
text = text.replace(/\[(—\s?)*\]/g, '');
//gap of 3?
text = text.replace(/\[---\]/g, '');
//[— — —ca.x-y— — —]
text = text.replace(/\[— — —ca\.([1-9][0-9]*)((-)([1-9][0-9]*))?— — —\]/g, '');
//[— — — —ca.x-y— — — —]
text = text.replace(/\[— — — —ca\.([1-9][0-9]*)((-)([1-9][0-9]*))?— — — —\]/g, '');
//[—ca. x— ]
text = text.replace(/\[(-|–\s?){1,20}ca\.(\s?)([1-9][0-9]*)?(\s?)(-|–\s?){1,20}\]/g, '');
//Line lost of unknown extent ; ------?
text = text.replace(/\------\?/g, '');
//Line lost of unknown extent ; [------?]
text = text.replace(/\[\------\?\]/g, '');
//Line lost of unknown extent ; [------?]
text = text.replace(/\[\---\?\]/g, '');
//beginning lost
text = text.replace(/\[(-|–|\—\s?){1,20}([^\x00-\x7F]*[aA-zZ]*)\]/g, '');
//Beginning of line lost, unknown extent ; with restition of word at end [------word]
//[- - - - - - - - - - γυμνα]-
text = text.replace(/\[(-|–|\—\s?){1,20}([^\x00-\x7F]*[aA-zZ]*)\]/g, '$2');
//Beginning of line lost, unknown extent ; with RASURA of word at end [------word]
//[- - - - - - - - - - γυμνα]-
text = text.replace(/(?:⟦|〚)(-|–|\—\s?){1,20}([^\x00-\x7F]*[aA-zZ]*)(?:⟧|〛)/g, '$2
');
//End of line lost, unknown extent ; with restition of word at beginning [word ---]
text = text.replace(
/* /\[(?!(\u2013|\u2014))([^\x00-\x7F]*[aA-zZ]*)((\s?)(\u2013|\u2014)\s?){1,20}\]/g,*/
/* /\[(?!([\-\–\—]))([^\x00-\x7F]*[aA-zZ]*)((\s?)([\-\—\–])\s?){1,20}\]/g, //==>before 31/03/2020 and attempt to match [wor word - - -]*/
/\[(?!([\-\–\—]))(((?!([\-\–\—\[\]]))[^\x00-\x7F]*[aA-zZ]*(\s?)){1,10})(([\-\—\–])\s?){1,20}\]/g,
'$2');
//End of line lost, unknown extent ; ---]
text = text.replace(
/(([\-\—\–])\s?){1,20}\]/g,
'');
//Cleaning [
text = text.replace(/\[/g, '');
//CLeaning <
text = text.replace(/<\/expan> <\/supplied> <');
//Cleaning TEXT[
text = text.replace(/([^\x00-\x7F]*?[aA-zZ]*?)\]/g,
'$1');
//Cleaning
text = text.replace(/<\/abbr>/g, '')
//Cleaning restitutions not dealt with by previous regex
//text + ---- in lacuna
const regexSuppliedClean = /\[/g;
const substSuppliedClean = '';
text = text.replace(regexSuppliedClean, substSuppliedClean);
const regexSuppliedCleanClose = /\]/g;
const substSuppliedCleanClose = '';
text = text.replace(regexSuppliedCleanClose, substSuppliedCleanClose);
//Cleaning
text = text.replace(/<\/ex><\/supplied><\/expan>/g, '');
/*//Cleaning gtgt
text = text.replace(/gt<\/supplied>gt<\/abbr>/g,
, '$1gt');
*/
// CLEANING - - -
text = text.replace(/((\s?(\-|\—|\–)\s?){1,20})<\/supplied>/g,
'')
text = text.replace(/((\s?(\-|\—|\–)\s?){1,20})<\/supplied>/g,
'')
//CLEAING - - -
text = text.replace(/((\s?(\-|\—|\–)\s?){1,20})/g,
'')
//Cleaning:
text = text.replace(/<\/supplied><\/supplied>/g
, '');
//CLEANING
text = text.replace(/ <\/supplied>/g, '');
//CLEANING \s?
text = text.replace(/\s?<\/del>/g, '');
//CLEANING \s?
text = text.replace(/<\/supplied>\s?<\/supplied>/g, '');
//CLEANING
<\/supplied>$2$3');
//Cleaning not processed - - - in middle lacuna
text = text.replace(
/(\s?([\-\—\–])\s?){1,20}/g,
'');
//Supplied with ] in an abbreviation
text = text.replace(/\[(.[^\[]*)(\s)([^\x00-\x7F]*[aA-zZ]*)\]([^\x00-\x7F]*[aA-zZ]*)\(([^\x00-\x7F]*[aA-zZ]*)\)/g,
'$1$3$4$5');
/*//Equivalent to previous but on ending
text = text.replace(/\[([^\x00-\x7F]*[aA-zZ]*)\s?(-|–\s?){1,20}\]/g, '$1');
*/
//illegible charactes +++
const regexIllegibleCharacter = /([+])+/g;
text = text.replace(regexIllegibleCharacter, function (match) {
console.log('Ici match:' + match.length);
return '';
});
//gap charachter with dot
const regexGapCharacter = /\[(․{1,20})\]/g;
text = text.replace(regexGapCharacter, function (match) {
console.log('Ici match:' + match.length);
const length = match.length - 2;
return '';
});
/* CLEANING opening supplied followed by GAP*/
text = text.replace(/ \)/g;
const substUnclearClean = '';
text = text.replace(regexUnclearClean, substUnclearClean);
/* //Cleaning supplied ending with ? — —]
var regexSuppliedCleanClose2 = /(\? — —\])/g;
var substSuppliedCleanClose2 = '';
var text = text.replace(regexSuppliedCleanClose2, substSuppliedCleanClose2);
*/
//Cleaning li
text = text.replace(/()((?:[^\x00-\x7F]*?[aA-zZ]*?)*)<\/supplied>/g,
'$1$2');
//Cleaning
text = text.replace(/()<\/supplied>/g,
'$1');
//Cleaning li
text = text.replace(/()((?:[^\x00-\x7F]*?[aA-zZ]*?)*)<\/supplied>/g,
'$1$2');
//Cleaning
text = text.replace(/()<\/supplied>/g,
'$1');
//Cleaning lb not preceded by a carraige
text = text.replace(/(\/\>)\s(\)/g, "$1\n$2")
//Cleaning not full line in lacuna
text = text.replace(/unit=\"line\"\/>\s(\w)/g, 'unit="line"/>$1');
//∙
text = text.replace(/ ?∙ ?/g, ' ▴ ');
/* text = text.replace(/ ?❦ ?/g, '❦');*/
text = text.replace(/ ?𐆖 ?/g, ' ');
text = text.replace(/❦/g, ' ❦ ');
//Cleaning double space
text = text.replace(/\s\s/g, ' ');
/* Centered WORDS*/
/*TODO: check if space after lb*/
// var text = text.replace(/