Index: gc_core/js/text.js
==================================================================
--- gc_core/js/text.js
+++ gc_core/js/text.js
@@ -54,127 +54,11 @@
helpers.logerror(e);
return "\n# Error. Data: " + oErr.toString();
}
}
-function addHtmlEntities (sParagraph) {
- if (sParagraph.includes("&")) {
- sParagraph = sParagraph.replace(/&/g, "&");
- }
- if (sParagraph.includes("<")) {
- sParagraph = sParagraph.replace(//g, ">");
- }
- return sParagraph;
-}
-
-function createHTMLBlock (sParagraph, iParagraph) {
- let sClassName = (sParagraph.includes('' + sParagraph + '
\n'
- + '×
'
- + '
Éditer
'
- + '
Réanalyser
\n';
-}
-
-function tagParagraph (sParagraph, iParagraph, aGrammErr, aSpellErr, bDebug=false) {
- // Returns a text with with underlined errors and messages in tooltip
- try {
- if (aGrammErr.length === 0 && aSpellErr.length === 0) {
- return sParagraph;
- }
- aGrammErr.push(...aSpellErr);
- aGrammErr.sort(function (a, b) {
- if (a["nStart"] < b["nStart"])
- return 1;
- if (a["nStart"] > b["nStart"])
- return -1;
- return 0;
- });
-
- let nErr = aGrammErr.length - 1; // we count errors to give them an identifier
- let nStartLastErr = sParagraph.length;
- for (let oErr of aGrammErr) {
- let sErrId = iParagraph.toString() + "_" + nErr.toString();
- let nStart = oErr["nStart"];
- let nEnd = oErr["nEnd"];
- if (nEnd <= nStartLastErr) {
- oErr["sId"] = sErrId;
- if (oErr['sType'] !== 'WORD') {
- // Grammar Error
- sParagraph = sParagraph.slice(0, nStart)
- + ''
- + sParagraph.slice(nStart, nEnd)
- + ''
- + getGrammarErrorHTML(oErr, bDebug) + ''
- + "" + sParagraph.slice(nEnd);
- } else {
- // Spelling error
- sParagraph = sParagraph.slice(0, nStart)
- + ''
- + sParagraph.slice(nStart, nEnd)
- + ''
- + getSpellingErrorHTML(oErr) + ''
- + "" + sParagraph.slice(nEnd);
- }
- nStartLastErr = nStart;
- }
- nErr -= 1;
- }
- return sParagraph;
- }
- catch (e) {
- helpers.logerror(e);
- return "# Error.";
- }
-}
-
-function getGrammarErrorHTML (oErr, bDebug=false) {
- // Returns an error oErr as a readable error in HTML
- try {
- let sErr = '';
- if (bDebug) {
- sErr += ''
- + ''
- + oErr['nStart'] + ":" + oErr['nEnd'] + ' · #' + oErr['sRuleId'] + " +";
- }
- sErr += oErr["sMessage"];
- sErr += ' IGNORER';
- if (oErr["URL"] !== "") {
- sErr += ' Infos…';
- }
- if (oErr["aSuggestions"].length > 0) {
- sErr += '
Suggestions :
';
- let iSugg = 0;
- for (let sSugg of oErr["aSuggestions"]) {
- sErr += '' + sSugg + ' ';
- iSugg += 1;
- }
- }
- return sErr;
- }
- catch (e) {
- helpers.logerror(e);
- return '# Error. Data: ' + oErr.toString();
- }
-}
-
-function getSpellingErrorHTML (oErr) {
- // Returns an error oErr as a readable error in HTML
- try {
- let sErr = 'Mot inconnu du dictionnaire.';
- sErr += ' IGNORER';
- sErr += '
Suggestions :
';
- return sErr;
- }
- catch (e) {
- helpers.logerror(e);
- return '# Error. Data: ' + oErr.toString();
- }
-}
-
if (typeof(exports) !== 'undefined') {
exports.getParagraph = getParagraph;
- exports.addHtmlEntities = addHtmlEntities;
- exports.createHTMLBlock = createHTMLBlock;
- exports.tagParagraph = tagParagraph;
+ exports.wrap = wrap;
exports.getReadableError = getReadableError;
}