mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-28 02:50:27 +00:00
Add rule attribute for WikiText AST nodes
This commit is contained in:
parent
4200495055
commit
d3e62ec56a
@ -215,6 +215,8 @@ WikiParser.prototype.parsePragmas = function() {
|
||||
// Set the start and end positions of the pragma rule if
|
||||
if (subTree[0].start === undefined) subTree[0].start = start;
|
||||
if (subTree[subTree.length - 1].end === undefined) subTree[subTree.length - 1].end = this.pos;
|
||||
var rule = Object.getPrototypeOf(nextMatch.rule);
|
||||
for (const node of subTree) node.rule = rule;
|
||||
// Quick hack; we only cope with a single parse tree node being returned, which is true at the moment
|
||||
currentTreeBranch.push.apply(currentTreeBranch,subTree);
|
||||
subTree[0].children = [];
|
||||
@ -244,13 +246,15 @@ WikiParser.prototype.parseBlock = function(terminatorRegExpString) {
|
||||
if (subTree[0].start === undefined) subTree[0].start = start;
|
||||
if (subTree[subTree.length - 1].end === undefined) subTree[subTree.length - 1].end = this.pos;
|
||||
}
|
||||
var rule = Object.getPrototypeOf(nextMatch.rule);
|
||||
for (const node of subTree) node.rule = rule;
|
||||
return subTree;
|
||||
}
|
||||
// Treat it as a paragraph if we didn't find a block rule
|
||||
var start = this.pos;
|
||||
var children = this.parseInlineRun(terminatorRegExp);
|
||||
var end = this.pos;
|
||||
return [{type: "element", tag: "p", children: children, start: start, end: end }];
|
||||
return [{type: "element", tag: "p", children: children, start: start, end: end, parseRule: null }];
|
||||
};
|
||||
|
||||
/*
|
||||
@ -349,6 +353,8 @@ WikiParser.prototype.parseInlineRunUnterminated = function(options) {
|
||||
if (subTree[0].start === undefined) subTree[0].start = start;
|
||||
if (subTree[subTree.length - 1].end === undefined) subTree[subTree.length - 1].end = this.pos;
|
||||
}
|
||||
var rule = Object.getPrototypeOf(nextMatch.rule);
|
||||
for (const node of subTree) node.rule = rule;
|
||||
tree.push.apply(tree,subTree);
|
||||
// Look for the next run rule
|
||||
nextMatch = this.findNextMatch(this.inlineRules,this.pos);
|
||||
@ -407,6 +413,8 @@ WikiParser.prototype.parseInlineRunTerminatedExtended = function(terminatorRegEx
|
||||
if (subTree[0].start === undefined) subTree[0].start = start;
|
||||
if (subTree[subTree.length - 1].end === undefined) subTree[subTree.length - 1].end = this.pos;
|
||||
}
|
||||
var rule = Object.getPrototypeOf(inlineRuleMatch.rule);
|
||||
for (const node of subTree) node.rule = rule;
|
||||
tree.push.apply(tree,subTree);
|
||||
// Look for the next inline rule
|
||||
inlineRuleMatch = this.findNextMatch(this.inlineRules,this.pos);
|
||||
@ -433,7 +441,7 @@ WikiParser.prototype.pushTextWidget = function(array,text,start,end) {
|
||||
text = $tw.utils.trim(text);
|
||||
}
|
||||
if(text) {
|
||||
array.push({type: "text", text: text, start: start, end: end});
|
||||
array.push({type: "text", text: text, start: start, end: end, parseRule: null});
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user