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, '