/* Functions concerned with parsing TiddlyWiki files */ var tiddlerInput = require("./TiddlerInput.js"), utils = require("./Utils.js"); var tiddlyWikiInput = exports; /* Parses the text of a TiddlyWiki HTML file, and returns the tiddlers as an array of hashmaps of raw fields. */ tiddlyWikiInput.parseTiddlyWiki = function(tiddlywikidoc) { var results = [], storeAreaPos = locateStoreArea(tiddlywikidoc); if(storeAreaPos) { 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, fields = tiddlerInput.parseTiddlerDiv(tiddlywikidoc.substring(startPos,endPos)); fields.text = utils.htmlDecode(fields.text); results.push(fields); startPos = endPos; match = endOfDivRegExp.exec(tiddlywikidoc); } } return results; } function locateStoreArea(tiddlywikidoc) { var startSaveArea = '