Browse Source

Fix assessment output generation to remove html escape characters and entities

Lucas de Souza 3 years ago
parent
commit
0643b1cbe8
1 changed files with 16 additions and 20 deletions
  1. 16 20
      js/util/outputTest.js

+ 16 - 20
js/util/outputTest.js

@@ -1,7 +1,6 @@
-import { Output } from './../io/output';
+import { Output } from "./../io/output";
 
 export class OutputTest extends Output {
-
   constructor () {
     super();
     this.list = [];
@@ -10,7 +9,7 @@ export class OutputTest extends Output {
 
   write (text, newLine = false) {
     if (this.currentLine == null) {
-      this.currentLine = this.list.push('') - 1;
+      this.currentLine = this.list.push("") - 1;
     }
 
     this.list[this.currentLine] += text;
@@ -20,25 +19,22 @@ export class OutputTest extends Output {
   }
 
   sendOutput (text) {
-    let output = '' + text;
-    if (output.indexOf('\n') !== -1) {
-      const outputList = output.split('\n');
-      let last = outputList.pop();
-      outputList.forEach( t => {
-        t = t.replace(/\t/g, '  ');
-        t = t.replace(/\s/g, " ");
-        if (t.length == 0)
-          this.currentLine = null;
-        else
-          this.write(t, true);
+    const output = "" + text;
+    if (output.indexOf("\n") !== -1) {
+      const outputList = output.split("\n");
+      const last = outputList.pop();
+      outputList.forEach((t) => {
+        //t = t.replace(/\t/g, '  ');
+        //t = t.replace(/\s/g, " ");
+        if (t.length == 0) this.currentLine = null;
+        else this.write(t, true);
       });
-      last = last.replace(/\t/g, '  ');
-      last = last.replace(/\s/g, " ");
-      if (last.length != 0)
-        this.write(last);
+      //last = last.replace(/\t/g, '  ');
+      //last = last.replace(/\s/g, " ");
+      if (last.length != 0) this.write(last);
     } else {
-      output = output.replace(/\t/g, '  ');
-      output = output.replace(/\s/g, " ");
+      //output = output.replace(/\t/g, '  ');
+      //output = output.replace(/\s/g, " ");
       this.write(output);
     }
   }