diff --git a/cms/static/js/speed-editor.js b/cms/static/js/speed-editor.js
index 57a47f8e2f..9ff7c0248e 100644
--- a/cms/static/js/speed-editor.js
+++ b/cms/static/js/speed-editor.js
@@ -96,18 +96,18 @@ function updateXML() {
var xml = val;
// replace headers
- xml = xml.replace(/(^.*)\n(?=\=\=+)/g, '
$1
');
- xml = xml.replace(/\=\=+/g, '');
+ xml = xml.replace(/(^.*?$)(?=\n\=\=+$)/gm, '$1
');
+ xml = xml.replace(/\n^\=\=+$/gm, '');
// group multiple choice answers
- xml = xml.replace(/(\(.?\).*\n*)+/g, function(match, p) {
+ xml = xml.replace(/(^\s*\(.?\).*?$\n*)+/gm, function(match, p) {
var groupString = '\n';
groupString += ' \n';
var options = match.split('\n');
for(var i = 0; i < options.length; i++) {
if(options[i].length > 0) {
- var value = options[i].split(/\)\s*/)[1];
- var correct = /\(x\)/i.test(options[i]);
+ var value = options[i].split(/^\s*\(.?\)\s*/)[1];
+ var correct = /^\s*\(x\)/i.test(options[i]);
groupString += ' ' + value + '\n';
}
}
@@ -117,14 +117,14 @@ function updateXML() {
});
// group check answers
- xml = xml.replace(/(\[.?\].*\n*)+/g, function(match, p) {
+ xml = xml.replace(/(^\s*\[.?\].*?$\n*)+/gm, function(match, p) {
var groupString = '\n';
groupString += ' \n';
var options = match.split('\n');
for(var i = 0; i < options.length; i++) {
if(options[i].length > 0) {
- var value = options[i].split(/\]\s*/)[1];
- var correct = /\[x\]/i.test(options[i]);
+ var value = options[i].split(/^\s*\[.?\]\s*/)[1];
+ var correct = /^\s*\[x\]/i.test(options[i]);
groupString += ' ' + value + '\n';
}
}
@@ -134,12 +134,12 @@ function updateXML() {
});
// replace videos
- xml = xml.replace(/\{\{video\s(.*)\}\}/g, '\n\n');
+ xml = xml.replace(/\{\{video\s(.*?)\}\}/g, '\n\n');
// replace string and numerical
- xml = xml.replace(/(?:\n|^)\=\s*(.*)/g, function(match, p) {
+ xml = xml.replace(/^\=\s*(.*?$)/gm, function(match, p) {
var string;
- var params = /(.*)\+\-\s*(.*)/.exec(p);
+ var params = /(.*?)\+\-\s*(.*?)/.exec(p);
if(parseFloat(p)) {
if(params) {
string = '\n';
@@ -156,22 +156,23 @@ function updateXML() {
});
// replace selects
- xml = xml.replace(/\[\[(.+)\]\]/g, function(match, p) {
+ xml = xml.replace(/\[\[(.+?)\]\]/g, function(match, p) {
var selectString = '\n\n';
selectString += ' \n';
selectString += '\n\n';
return selectString;
});
// split scripts and wrap paragraphs
- var splits = xml.split(/(\<\/?script.*\>)/g);
+ var splits = xml.split(/(\<\/?script.*?\>)/g);
var scriptFlag = false;
for(var i = 0; i < splits.length; i++) {
if(/\