1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-08-07 22:33:50 +00:00

refactor: use serialize in rules

This commit is contained in:
lin onetwo 2024-06-13 01:34:18 +08:00
parent f882cbd7af
commit be3f037a57
3 changed files with 9 additions and 9 deletions

View File

@ -57,7 +57,7 @@ exports.parse = function() {
}]; }];
}; };
exports.getText = function(tree) { exports.serialize = function(tree) {
return "\n```" + tree.attributes.language.value + "\n" + tree.attributes.code.value + "\n```\n"; return "\n```" + tree.attributes.language.value + "\n" + tree.attributes.code.value + "\n```\n";
} }

View File

@ -31,8 +31,8 @@ exports.parse = function() {
return [{type: "element", tag: "hr"}]; return [{type: "element", tag: "hr"}];
}; };
exports.getText = function() { exports.serialize = function() {
return "---"; return "\n---\n";
} }
})(); })();

View File

@ -137,15 +137,15 @@ exports.serializeParseTree = function serializeParseTree(tree, tiddlerType) {
output.push(tree.text); output.push(tree.text);
} else { } else {
var Parser = $tw.wiki.getParser(tiddlerType); var Parser = $tw.wiki.getParser(tiddlerType);
var Rule = Parser.prototype.blockRuleClasses[tree.type] || var Rule = Parser.prototype.blockRuleClasses[tree.rule] ||
Parser.prototype.inlineRuleClasses[tree.type] || Parser.prototype.inlineRuleClasses[tree.rule] ||
Parser.prototype.pragmaRuleClasses[tree.type]; Parser.prototype.pragmaRuleClasses[tree.rule];
if(Rule && Rule.prototype.getText) { if(Rule && Rule.prototype.serialize) {
output.push(Rule.prototype.getText(tree)); output.push(Rule.prototype.serialize(tree));
} }
} }
if(tree.children) { if(tree.children) {
return getParseTreeText(tree.children); return serializeParseTree(tree.children);
} }
} }
return output.join(""); return output.join("");