diff --git a/js/FileRetriever.js b/js/FileRetriever.js index fdcf21db8..a7cfafc0b 100644 --- a/js/FileRetriever.js +++ b/js/FileRetriever.js @@ -15,7 +15,6 @@ var fileRequestQueue = utils.queue(function(task,callback) { }); },10); - // Retrieve a file given a filepath specifier and a context path. If the filepath isn't an absolute // filepath or an absolute URL, then it is interpreted relative to the context path, which can also be // a filepath or a URL. It returns the final path used to reach the file. On completion, the callback diff --git a/js/Recipe.js b/js/Recipe.js index ff85bdc24..0edb5b785 100755 --- a/js/Recipe.js +++ b/js/Recipe.js @@ -139,9 +139,9 @@ Recipe.prototype.readIngredient = function(filepath,contextPath,callback) { // Return a string of the cooked recipe Recipe.prototype.cook = function() { - var template = this.ingredients.template ? this.ingredients.template[0].fields.text : ""; - var out = []; - var me = this; + var template = this.ingredients.template ? this.ingredients.template[0].fields.text : "", + out = [], + me = this; template.split("\n").forEach(function(line) { var templateRegExp = /^(?:)|(?:<!--@@(.*)@@-->)$/gi; var match = templateRegExp.exec(line); @@ -157,9 +157,9 @@ Recipe.prototype.cook = function() { // Output all the tiddlers in the recipe with a particular marker Recipe.prototype.outputIngredient = function(out,marker) { - var ingredient = this.ingredients[marker]; - var outputType = Recipe.ingredientOutputMapper[marker] || "raw"; - var outputter = Recipe.ingredientOutputter[outputType]; + var ingredient = this.ingredients[marker], + outputType = Recipe.ingredientOutputMapper[marker] || "raw", + outputter = Recipe.ingredientOutputter[outputType]; if(outputter && ingredient) { outputter(out,ingredient); } @@ -195,8 +195,8 @@ Recipe.ingredientOutputter = { javascript: function(out,ingredient) { // Lines starting with //# are removed from javascript tiddlers for(var t=0; t with the the ".shadow" suffix removed from the title for(var t=0; t]*)>((?:.|\n)*)<\/div>\s*$/gi; - var subDivRegExp = /^\s*
((?:.|\n)*)<\/pre>\s*$/gi;
-	var attrRegExp = /\s*([^=\s]+)\s*=\s*"([^"]*)"/gi;
-	var match = divRegExp.exec(text);
+	var divRegExp = /^\s*]*)>((?:.|\n)*)<\/div>\s*$/gi,
+		subDivRegExp = /^\s*
((?:.|\n)*)<\/pre>\s*$/gi,
+		attrRegExp = /\s*([^=\s]+)\s*=\s*"([^"]*)"/gi,
+		match = divRegExp.exec(text);
 	if(match) {
 		var subMatch = subDivRegExp.exec(match[2]); // Body of the 
tag if(subMatch) { diff --git a/js/TiddlerOutput.js b/js/TiddlerOutput.js index 23f6cc57a..fdfee2c0d 100755 --- a/js/TiddlerOutput.js +++ b/js/TiddlerOutput.js @@ -10,8 +10,8 @@ var tiddlerOutput = exports; Output a tiddler as a .tid file */ tiddlerOutput.outputTiddler = function(tid) { - var result = []; - var outputAttribute = function(name,value) { + var result = [], + outputAttribute = function(name,value) { result.push(name + ": " + value + "\n"); }; for(var t in tid.fields) { @@ -47,10 +47,10 @@ options - options: omitPrecedingLineFeed - determines if a linefeed is inserted between the
 tag and the text
 */
 tiddlerOutput.outputTiddlerDiv = function(tid) {
-	var result = [];
-	var outputAttribute = function(name,value) {
-		result.push(" " + name + "=\"" + value + "\"");
-	};
+	var result = [],
+		outputAttribute = function(name,value) {
+			result.push(" " + name + "=\"" + value + "\"");
+		};
 	result.push("\s*)/gi;
-		var startPos = storeAreaPos[0];
+		var endOfDivRegExp = /(<\/div>\s*)/gi,
+			startPos = storeAreaPos[0];
 		endOfDivRegExp.lastIndex = startPos;
 		var match = endOfDivRegExp.exec(tiddlywikidoc);
 		while(match && startPos < storeAreaPos[1]) {
-			var endPos = endOfDivRegExp.lastIndex;
-			var fields = tiddlerInput.parseTiddlerDiv(tiddlywikidoc.substring(startPos,endPos));
+			var endPos = endOfDivRegExp.lastIndex,
+				fields = tiddlerInput.parseTiddlerDiv(tiddlywikidoc.substring(startPos,endPos));
 			fields.text = utils.htmlDecode(fields.text);
 			results.push(fields);
 			startPos = endPos;
@@ -33,17 +33,17 @@ tiddlyWikiInput.parseTiddlyWiki = function(tiddlywikidoc) {
 
 function locateStoreArea(tiddlywikidoc)
 {
-	var startSaveArea = '
'; - var startSaveAreaRegExp = /
/gi; - var endSaveArea = ''; - var endSaveAreaCaps = ''; - var posOpeningDiv = tiddlywikidoc.search(startSaveAreaRegExp); - var limitClosingDiv = tiddlywikidoc.indexOf("<"+"!--POST-STOREAREA--"+">"); + var startSaveArea = '
', + startSaveAreaRegExp = /
/gi, + endSaveArea = '', + endSaveAreaCaps = '', + posOpeningDiv = tiddlywikidoc.search(startSaveAreaRegExp), + limitClosingDiv = tiddlywikidoc.indexOf("<"+"!--POST-STOREAREA--"+">"); if(limitClosingDiv == -1) { limitClosingDiv = tiddlywikidoc.indexOf("<"+"!--POST-BODY-START--"+">"); } - var start = limitClosingDiv == -1 ? tiddlywikidoc.length : limitClosingDiv; - var posClosingDiv = tiddlywikidoc.lastIndexOf(endSaveArea,start); + var start = limitClosingDiv == -1 ? tiddlywikidoc.length : limitClosingDiv, + posClosingDiv = tiddlywikidoc.lastIndexOf(endSaveArea,start); if(posClosingDiv == -1) { posClosingDiv = tiddlywikidoc.lastIndexOf(endSaveAreaCaps,start); } diff --git a/server.js b/server.js index b81485a36..cb85debc8 100644 --- a/server.js +++ b/server.js @@ -14,10 +14,10 @@ var filename = process.argv[2]; http.createServer(function(request, response) { response.writeHead(200, {"Content-Type": "text/html"}); - var store = new TiddlyWiki(); - var theRecipe = new Recipe(store,filename,function() { - response.end(theRecipe.cook(), "utf-8"); - }); + var store = new TiddlyWiki(), + theRecipe = new Recipe(store,filename,function() { + response.end(theRecipe.cook(), "utf-8"); + }); }).listen(8000); sys.puts("Server running at http://127.0.0.1:8000/");