mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-08-08 23:03:50 +00:00
feat: allow $tw.utils.getParseTreeText to render other rules' text
This commit is contained in:
parent
37338b13e4
commit
8a12498fa9
@ -106,7 +106,7 @@ exports.findParseTreeNode = function(nodeArray,search) {
|
|||||||
/*
|
/*
|
||||||
Helper to get the text of a parse tree node or array of nodes
|
Helper to get the text of a parse tree node or array of nodes
|
||||||
*/
|
*/
|
||||||
exports.getParseTreeText = function getParseTreeText(tree) {
|
exports.getParseTreeText = function getParseTreeText(tree, tiddlerType) {
|
||||||
var output = [];
|
var output = [];
|
||||||
if($tw.utils.isArray(tree)) {
|
if($tw.utils.isArray(tree)) {
|
||||||
$tw.utils.each(tree,function(node) {
|
$tw.utils.each(tree,function(node) {
|
||||||
@ -115,6 +115,14 @@ exports.getParseTreeText = function getParseTreeText(tree) {
|
|||||||
} else {
|
} else {
|
||||||
if(tree.type === "text") {
|
if(tree.type === "text") {
|
||||||
output.push(tree.text);
|
output.push(tree.text);
|
||||||
|
} else {
|
||||||
|
var Parser = $tw.wiki.getParser(tiddlerType);
|
||||||
|
var Rule = Parser.prototype.blockRuleClasses[tree.type] ||
|
||||||
|
Parser.prototype.inlineRuleClasses[tree.type] ||
|
||||||
|
Parser.prototype.pragmaRuleClasses[tree.type];
|
||||||
|
if(Rule && Rule.prototype.getText) {
|
||||||
|
output.push(Rule.prototype.getText(tree));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(tree.children) {
|
if(tree.children) {
|
||||||
return getParseTreeText(tree.children);
|
return getParseTreeText(tree.children);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user