/** ========================================================================= * Processor * Modify the prepared source ready to be written to an iframe * ========================================================================== */ var processor = (function () { var processor = {}; processor.blockingMethods = { kill: '', // RS: the empty comment in the end of the harness, ensures any // open comments are closed, and will ensure the harness is hidden // from the user. restore: '' }; /** * Grab the doctype from a string. * * Returns an object with doctype and tail keys. */ processor.getDoctype = (function () { // Cached regex // [\s\S] matches multiline doctypes var regex = //i; return function (str) { var doctype = (str.match(regex) || [''])[0], tail = str.substr(doctype.length); return { doctype: doctype, tail: tail }; }; }()); /** * Replace HTML characters with encoded equivatents for debug mode. */ processor.debug = function (source) { return '
' + source.replace(/[<>&]/g, function (m) {
if (m == '<') return '<';
if (m == '>') return '>';
if (m == '&') return '&';
}) + '';
};
/**
* Render – build the final source code to be written to the iframe. Takes
* the original source and an options object.
*/
processor.render = function (source, options) {
options = options || [];
source = source || '';
var combinedSource = [],
realtime = (options.requested !== true),
noRealtimeJs = (options.includeJsInRealtime === false);
// If the render was realtime and we don't want javascript in realtime
// renders – Auto-run JS is unchecked – then strip out the Javascript
if (realtime && noRealtimeJs) {
source = source.replace(/