mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-05-09 10:54:08 +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) {
|
exports.parseText = function(type,text,options) {
|
||||||
text = text || "";
|
text = text || "";
|
||||||
options = options || {};
|
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
|
// Select a parser
|
||||||
var Parser = $tw.Wiki.parsers[type];
|
var Parser = $tw.Wiki.parsers[type];
|
||||||
if(!Parser && $tw.utils.getFileExtensionInfo(type)) {
|
if(!Parser && $tw.utils.getFileExtensionInfo(type)) {
|
||||||
@ -1046,13 +1058,7 @@ exports.parseText = function(type,text,options) {
|
|||||||
if(!Parser) {
|
if(!Parser) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// Return the parser instance
|
return Parser;
|
||||||
return new Parser(type,text,{
|
|
||||||
parseAsInline: options.parseAsInline,
|
|
||||||
wiki: this,
|
|
||||||
_canonical_uri: options._canonical_uri,
|
|
||||||
configTrimWhiteSpace: options.configTrimWhiteSpace
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user