Browse Source

fixed macro replacement; added space behind '<' replacement; all checkboxes with []; added macros replacement

tags/1.0.3^0
Robin Thoni 8 years ago
parent
commit
6f8a9083d5
1 changed files with 7 additions and 11 deletions
  1. 7
    11
      app/controllers/home.controller.js

+ 7
- 11
app/controllers/home.controller.js View File

@@ -37,7 +37,8 @@ angular.module('app')
37 37
                     .trim();
38 38
                 $scope.macros.forEach(function(macro)
39 39
                 {
40
-                    text = text.replace(new RegExp($scope.escapeRegExp(macro.latex) + "([^a-zA-Z])", "g"), function($1, $2)
40
+                    var regex = macro.latex.match(/[a-zA-Z0-9]$/) != null ? "([^a-zA-Z0-9])" : "";
41
+                    text = text.replace(new RegExp($scope.escapeRegExp(macro.latex) + regex, "g"), function($1, $2)
41 42
                     {
42 43
                         return macro.html + $2;
43 44
                     });
@@ -92,18 +93,11 @@ angular.module('app')
92 93
                 {
93 94
                     $scope.Data.Output += question.Text + "\n";
94 95
 
95
-                    var goodAnswersCount = 0;
96
-                    question.Answers.forEach(function(answer)
97
-                    {
98
-                        if (answer.Correct) {
99
-                            ++goodAnswersCount;
100
-                        }
101
-                    });
96
+
102 97
 
103 98
                     question.Answers.forEach(function(answer)
104 99
                     {
105
-                        $scope.Data.Output += "\t" + (goodAnswersCount > 1 ? "[" : "(") + (answer.Correct ? "x" : "") +
106
-                            (goodAnswersCount > 1 ? "]" : ")") + answer.Text + "\n";
100
+                        $scope.Data.Output += "\t[" + (answer.Correct ? "x" : "") + "]" + answer.Text + "\n";
107 101
                     });
108 102
                     $scope.Data.Output += "\n";
109 103
                 });
@@ -118,11 +112,13 @@ angular.module('app')
118 112
             $scope.addMacro("\\RR", "\\mathbb{R}");
119 113
             $scope.addMacro("\\CC", "\\mathbb{C}");
120 114
             $scope.addMacro("\\QQ", "\\mathbb{Q}");
115
+            $scope.addMacro("\\NN", "\\mathbb{N}");
116
+            $scope.addMacro("\\ZZ", "\\mathbb{Z}");
121 117
             $scope.addMacro("\\di", "\\displaystyle");
122 118
             $scope.addMacro("\\dd", "\\text{d}");
123 119
             $scope.addMacro("<<", "&#171;");
124 120
             $scope.addMacro(">>", "&#187;");
125
-            $scope.addMacro("<", "&#60;");
121
+            $scope.addMacro("<", "&#60; ");
126 122
             $scope.addMacro(">", "&#62;");
127 123
             $scope.addMacro("\\\'{E}", "&#201;");
128 124
             $scope.addMacro("\\\'{A}", "&#192;");

Loading…
Cancel
Save