mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-20 22:16:52 +00:00
refactor: extract a new $tw.wiki.getParser
This commit is contained in:
parent
4bda8cfee6
commit
37338b13e4
@ -1035,6 +1035,18 @@ Options include:
|
||||
exports.parseText = function(type,text,options) {
|
||||
text = text || "";
|
||||
options = options || {};
|
||||
var Parser = this.getParser(type,options)
|
||||
// Return the parser instance
|
||||
return new Parser(type,text,{
|
||||
parseAsInline: options.parseAsInline,
|
||||
wiki: this,
|
||||
_canonical_uri: options._canonical_uri,
|
||||
configTrimWhiteSpace: options.configTrimWhiteSpace
|
||||
});
|
||||
};
|
||||
|
||||
exports.getParser = function(type,options) {
|
||||
options = $tw.utils.extend({},options);
|
||||
// Select a parser
|
||||
var Parser = $tw.Wiki.parsers[type];
|
||||
if(!Parser && $tw.utils.getFileExtensionInfo(type)) {
|
||||
@ -1046,13 +1058,7 @@ exports.parseText = function(type,text,options) {
|
||||
if(!Parser) {
|
||||
return null;
|
||||
}
|
||||
// Return the parser instance
|
||||
return new Parser(type,text,{
|
||||
parseAsInline: options.parseAsInline,
|
||||
wiki: this,
|
||||
_canonical_uri: options._canonical_uri,
|
||||
configTrimWhiteSpace: options.configTrimWhiteSpace
|
||||
});
|
||||
return Parser;
|
||||
};
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user