diff --git a/epigraphista/javascript/epidoc_text_converter.js b/epigraphista/javascript/epidoc_text_converter.js index 85ef1fc..25fea6f 100644 --- a/epigraphista/javascript/epidoc_text_converter.js +++ b/epigraphista/javascript/epidoc_text_converter.js @@ -39,18 +39,24 @@ function convertLeidenToEpidoc (text) { // ///////////////////////// // // <> // + // visual explanation: + // https://regexper.com/#%3C%3C%28%28%3F%3A%5Ba-z%5D%7Cs%29%2B%29%3E%3E text = text.replace( RegExp('<<((?:[' + unicodeBlocks + ']|s)+)>>', 'g'), '$1' ) // [[exemplum]] // + // visual explanation: + // https://regexper.com/#%5C%5B%5C%5B%28%28%3F%3A%5Ba-z%5D%7Cs%29%2B%29%5C%5D%5C%5D text = text.replace( RegExp('\\[\\[((?:[' + unicodeBlocks + ']|s)+)\\]\\]', 'g'), '$1' ) // ((exemplum)) // + // visual explanation: + // https://regexper.com/#%5C%28%5C%28%28%28%3F%3A%5Ba-z%5D%7Cs%29%2B%29%5C%29%5C%29 text = text.replace( RegExp('\\(\\(((?:[' + unicodeBlocks + ']|s)+)\\)\\)', 'g'), '' @@ -61,44 +67,57 @@ function convertLeidenToEpidoc (text) { // ///////////////////////// // // // - // '' will match, but '<>' will NOT match. + // visual explanation: + // https://regexper.com/#%28%5B%5E%3C%5D%29%3C%28%28%3F%3A%5Ba-z%5D%7Cs%29%2B%29%3E%28%5B%5E%3E%5D%29 text = text.replace( - RegExp('([^<]){0,1}<((?:[' + unicodeBlocks + ']|s)+)>([^>]|$)', 'g'), + RegExp('([^<])<((?:[' + unicodeBlocks + ']|s)+)>([^>])', 'g'), '$1$2$3' ) // {exemplum} // + // visual explanation: + // https://regexper.com/#%7B%28%28%3F%3A%5Ba-z%5D%7Cs%29%2B%29%7D text = text.replace( RegExp('{((?:[' + unicodeBlocks + ']|s)+)}', 'g'), '$1' ) // [c.2] // + // visual explanation: + // https://regexper.com/#%5C%5Bc%5C.%28%28%3F%3A%5Cd%29%2B%29%5C%5D text = text.replace( /\[c\.((?:\d)+)\]/g, '' ) // [-] // + // visual explanation: + // https://regexper.com/#%5C%5B-%5C%5D text = text.replace( /\[-\]/g, '' ) // [- -] // + // visual explanation: + // https://regexper.com/#%28%5E%7C%5Cn%29%7B1%7D%28%5Cs%29%7B0%2C%7D%5C%5B-%5Cs-%5C%5D%28%5Cs%29%7B0%2C%7D%28%5Cn%7C%24%29%7B1%7D text = text.replace( - /(^|\n){1}([\s]){0,}\[\-\s\-\](\s){0,}(\n|$){1}/g, + /(^|\n){1}(\s){0,}\[-\s-\](\s){0,}(\n|$){1}/g, '$1\n' ) // [- -] ? // + // visual explanation: + // https://regexper.com/#%28%5E%7C%5Cn%29%7B1%7D%28%5B%5Cs%5D%29%7B0%2C%7D%5C%5B-%5Cs-%5C%5D%5Cs%5C%3F%28%5Cn%7C%24%29%7B1%7D text = text.replace( - /(^|\n){1}([\s]){0,}\[\-\s\-\]\s\?(\n|$){1}/g, + /(^|\n){1}([\s]){0,}\[-\s-\]\s\?(\n|$){1}/g, '$1' ) // [--] // - const lostCharactersRegExp = /([^\[]){0,1}\[([\-]+)\]([^\]]){0,1}/ + // visual explanation: + // https://regexper.com/#%28%5B%5E%5B%5D%29%5C%5B%28%5B-%5D%2B%29%5C%5D%28%5B%5E%5C%5D%5D%29 + const lostCharactersRegExp = /([^[])\[([-]+)\]([^\]])/ while (text.match(lostCharactersRegExp)) { text = text.replace( @@ -109,8 +128,10 @@ function convertLeidenToEpidoc (text) { ) } - // [. .] // - const lostRegExp = /\[([\.\s]+)\]/ + // [..] // + // visual explanation: + // https://regexper.com/#%5C%5B%28%5B.%5D%2B%29%5C%5D + const lostRegExp = /\[([.]+)\]/ while (text.match(lostRegExp)) { // Brackets are not counted! @@ -126,12 +147,16 @@ function convertLeidenToEpidoc (text) { text = text.replace(/\(!\)/g, '!') // (scil. exemplum) // + // visual explanation: + // https://regexper.com/#%5C%28scil%5C.%5Cs%28%28%3F%3A%5Ba-z%5D%7Cs%29%2B%29%5C%29 text = text.replace( - RegExp('\\(scil. ((?:[' + unicodeBlocks + ']|s)+)\\)', 'g'), + RegExp('\\(scil\\.\\s((?:[' + unicodeBlocks + ']|s)+)\\)', 'g'), '$1' ) // exemplum(- -) // + // visual explanation: + // https://regexper.com/#%28%5CS%2B%29%5C%28%28-%5Cs*%29%2B%5C%29 text = text.replace(/(\S+)\((-\s*)+\)/g, '$1') // (- -) // @@ -279,7 +304,7 @@ function convertLeidenToEpidoc (text) { // 6. [c.2] // 7. [-] // 8. [--] -// 9. [. .] +// 9. [..] // 10. (!) // 11. (scil. exemplum) // 12. exemplum(- -) @@ -300,9 +325,11 @@ function convertLeidenToEpidoc (text) { // 27. ++ // 28. ... -// Paste in the 'Inscription Text' textarea without the comments: +// Paste in the 'Inscription Text' textarea +// without the comment mark and with nothing else on the line : // [- -] // [- -] ? -// Paste in the 'Inscription Text' textarea and add a new line bellow: +// Paste in the 'Inscription Text' textarea +// without the comment mark and add a new line bellow: // exempl-