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:
parent
f882cbd7af
commit
be3f037a57
@ -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";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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";
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -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("");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user