diff --git a/js/Recipe.js b/js/Recipe.js index 22f90460b..f244bbe3f 100755 --- a/js/Recipe.js +++ b/js/Recipe.js @@ -302,18 +302,20 @@ Recipe.prototype.readTiddlerFile = function(filepath,baseDir,callback) { Recipe.prototype.cook = function() { var template = this.markers.template ? this.store.getTiddlerText(this.markers.template[0]) : "", out = [], - me = this; - template.split("\n").forEach(function(line) { + templateLines = template.split("\n"); + for(var line=0; line)|(?:<!--@@(.*)@@-->)$/gi; - var match = templateRegExp.exec(line); + var match = templateRegExp.exec(templateLines[line]); if(match) { var marker = match[1] === undefined ? match[2] : match[1]; - me.outputTiddlersForMarker(out,marker); + this.outputTiddlersForMarker(out,marker); } else { - out.push(line); + if(line !== templateLines.length-1) { + out.push(templateLines[line],"\n"); + } } - }); - return out.join("\n"); + } + return out.join(""); }; // Output all the tiddlers in the recipe with a particular marker @@ -325,7 +327,16 @@ Recipe.prototype.outputTiddlersForMarker = function(out,marker) { tiddlers = []; } if(outputter) { + if((out.length > 1) && (Recipe.compatibilityCheats[marker] === "suppressLeadingNewline")) { + var lastLine = out[out.length-1]; + if(lastLine.substr(-1) === "\n") { + out[out.length-1] = lastLine.substr(0,lastLine.length-1); + } + } outputter.call(this,out,tiddlers); + if(Recipe.compatibilityCheats[marker] === "addTrailingNewline") { + out.push("\n"); + } } }; @@ -333,6 +344,7 @@ Recipe.prototype.outputTiddlersForMarker = function(out,marker) { Recipe.tiddlerOutputMapper = { tiddler: "div", js: "javascript", + jslib: "javascript", jsdeprecated: "javascript", jquery: "javascript", shadow: "shadow", @@ -340,21 +352,26 @@ Recipe.tiddlerOutputMapper = { jsmodule: "jsmodule" }; +Recipe.compatibilityCheats = { + "prehead": "addTrailingNewline", + "posthead": "addTrailingNewline", + "prebody": "addTrailingNewline", + "postscript": "addTrailingNewline", + "title": "suppressLeadingNewline" +}; + Recipe.tiddlerOutputter = { raw: function(out,tiddlers) { // The default is just to output the raw text of the tiddler, ignoring any metadata for(var t=0; t for(var t=0; t