Store the parser list in the wiki constructor

print-window-tiddler
Jeremy Ruston 2013-04-25 17:40:12 +01:00
rodzic fb9c67f210
commit f487ea68d1
1 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -491,13 +491,13 @@ exports.clearCache = function(title) {
}; };
exports.initParsers = function(moduleType) { exports.initParsers = function(moduleType) {
// Install the new parser modules // Install the parser modules
$tw.wiki.parsers = {}; $tw.Wiki.parsers = {};
var self = this; var self = this;
$tw.modules.forEachModuleOfType("parser",function(title,module) { $tw.modules.forEachModuleOfType("parser",function(title,module) {
for(var f in module) { for(var f in module) {
if($tw.utils.hop(module,f)) { if($tw.utils.hop(module,f)) {
$tw.wiki.parsers[f] = module[f]; // Store the parser class $tw.Wiki.parsers[f] = module[f]; // Store the parser class
} }
} }
}); });
@ -514,12 +514,12 @@ Options include:
exports.parseText = function(type,text,options) { exports.parseText = function(type,text,options) {
options = options || {}; options = options || {};
// Select a parser // Select a parser
var Parser = this.parsers[type]; var Parser = $tw.Wiki.parsers[type];
if(!Parser && $tw.config.fileExtensionInfo[type]) { if(!Parser && $tw.config.fileExtensionInfo[type]) {
Parser = this.parsers[$tw.config.fileExtensionInfo[type].type]; Parser = $tw.Wiki.parsers[$tw.config.fileExtensionInfo[type].type];
} }
if(!Parser) { if(!Parser) {
Parser = this.parsers[options.defaultType || "text/vnd.tiddlywiki"]; Parser = $tw.Wiki.parsers[options.defaultType || "text/vnd.tiddlywiki"];
} }
if(!Parser) { if(!Parser) {
return null; return null;