/* Functions concerned with parsing representations of tiddlers */ "use strict"; var utils = require("./Utils.js"); var tiddlerOutput = exports; /* Output a tiddler as a .tid file */ tiddlerOutput.outputTiddler = function(tid) { var result = [], outputAttribute = function(name,value) { result.push(name + ": " + value + "\n"); }; for(var t in tid.fields) { switch(t) { case "text": // Ignore the text field break; case "tags": // Output tags as a list outputAttribute(t,tiddlerOutput.stringifyTags(tid.fields.tags)); break; case "modified": case "created": // Output dates in YYYYMMDDHHMM outputAttribute(t,utils.convertToYYYYMMDDHHMM(tid.fields[t])); break; default: // Output other attributes raw outputAttribute(t,tid.fields[t]); break; } } result.push("\n"); result.push(tid.fields.text); return result.join(""); } /* Output a tiddler as an HTML
tag and the text */ tiddlerOutput.outputTiddlerDiv = function(tid) { var result = [], outputAttribute = function(name,value) { result.push(" " + name + "=\"" + value + "\""); }; result.push("\n"); return result.join(""); } tiddlerOutput.stringifyTags = function(tags) { var results = []; for(var t=0; t\n"); result.push(utils.htmlEncode(tid.fields.text)); result.push("\n