|
@@ -24,7 +24,12 @@ angular.module('app')
|
24
|
24
|
text = text.replace(/\$([^\$]+)\$/g, function($1, $2)
|
25
|
25
|
{
|
26
|
26
|
return "\\(" + $2 + "\\)";
|
27
|
|
- }).replace("\n", "");
|
|
27
|
+ }).replace(/\\medskip/, "")
|
|
28
|
+ .replace(/\\begin\{.*\}/g, "")
|
|
29
|
+ .replace(/\\end\{.*\}/g, "")
|
|
30
|
+ .replace(/\n|\r|\r\n|\n\r/g, " ")
|
|
31
|
+ .replace(/ +/, " ")
|
|
32
|
+ .trim();
|
28
|
33
|
$scope.macros.forEach(function(macro)
|
29
|
34
|
{
|
30
|
35
|
text = text.replace(macro.latex, macro.html);
|
|
@@ -42,6 +47,7 @@ angular.module('app')
|
42
|
47
|
var questions = input.split("\\section");
|
43
|
48
|
questions.splice(0, 1);
|
44
|
49
|
|
|
50
|
+ var firstQuestion = null;
|
45
|
51
|
questions.forEach(function(questionStr)
|
46
|
52
|
{
|
47
|
53
|
var question = {
|
|
@@ -49,17 +55,19 @@ angular.module('app')
|
49
|
55
|
Answers: []
|
50
|
56
|
};
|
51
|
57
|
var responses = questionStr.split("\\item");
|
52
|
|
- question.Text = responses[0].replace(/^\*\{.*\}/, "")
|
53
|
|
- .replace(/\\medskip/g, "")
|
54
|
|
- .replace(/\\begin\{.*\}/g, "")
|
55
|
|
- .trim();
|
|
58
|
+ question.Text = responses[0].replace(/^\*\{.* ([0-9]+).*\}/, function($1, $2)
|
|
59
|
+ {
|
|
60
|
+ $2 = parseInt($2);
|
|
61
|
+ if (firstQuestion == null) {
|
|
62
|
+ firstQuestion = $2;
|
|
63
|
+ }
|
|
64
|
+ return "Question " + ($2 - firstQuestion + 1) + "\n";
|
|
65
|
+ });
|
56
|
66
|
question.Text = $scope.formatText(question.Text);
|
57
|
67
|
responses.splice(0, 1);
|
58
|
68
|
|
59
|
69
|
responses.forEach(function(answerStr) {
|
60
|
|
- answerStr = answerStr.replace(/\\medskip/, "")
|
61
|
|
- .replace(/\\end\{.*\}/g, "")
|
62
|
|
- .trim();
|
|
70
|
+ answerStr = answerStr.replace(/\\medskip/, "").trim();
|
63
|
71
|
var a = answerStr.match(/^\[[^\]\[]+\]/)[0];
|
64
|
72
|
answerStr = answerStr.substring(a.length, answerStr.length);
|
65
|
73
|
answerStr = $scope.formatText(answerStr);
|