mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-17 07:14:50 +00:00
Revert previous implementation
This commit is contained in:
parent
2a2fd1caa8
commit
09cc3b0b73
@ -32,7 +32,6 @@ options: see below:
|
|||||||
parseAsInline: true to parse text as inline instead of block
|
parseAsInline: true to parse text as inline instead of block
|
||||||
wiki: reference to wiki to use
|
wiki: reference to wiki to use
|
||||||
_canonical_uri: optional URI of content if text is missing or empty
|
_canonical_uri: optional URI of content if text is missing or empty
|
||||||
title: optional tiddler title to be available within this parse tree via the variable "thisTiddler"
|
|
||||||
*/
|
*/
|
||||||
var WikiParser = function(type,text,options) {
|
var WikiParser = function(type,text,options) {
|
||||||
this.wiki = options.wiki;
|
this.wiki = options.wiki;
|
||||||
@ -52,9 +51,8 @@ var WikiParser = function(type,text,options) {
|
|||||||
this.parseAsInline = options.parseAsInline;
|
this.parseAsInline = options.parseAsInline;
|
||||||
// Set current parse position
|
// Set current parse position
|
||||||
this.pos = 0;
|
this.pos = 0;
|
||||||
// Start with empty output and initialise insertion point
|
// Start with empty output
|
||||||
this.tree = [];
|
this.tree = [];
|
||||||
var topBranch = this.tree;
|
|
||||||
// Assemble the rule classes we're going to use
|
// Assemble the rule classes we're going to use
|
||||||
var pragmaRuleClasses, blockRuleClasses, inlineRuleClasses;
|
var pragmaRuleClasses, blockRuleClasses, inlineRuleClasses;
|
||||||
if(options.rules) {
|
if(options.rules) {
|
||||||
@ -84,22 +82,8 @@ var WikiParser = function(type,text,options) {
|
|||||||
// Instantiate the parser block and inline rules
|
// Instantiate the parser block and inline rules
|
||||||
this.blockRules = this.instantiateRules(blockRuleClasses,"block",0);
|
this.blockRules = this.instantiateRules(blockRuleClasses,"block",0);
|
||||||
this.inlineRules = this.instantiateRules(inlineRuleClasses,"inline",0);
|
this.inlineRules = this.instantiateRules(inlineRuleClasses,"inline",0);
|
||||||
// Set the "thisTiddler" variable
|
|
||||||
if(options.title) {
|
|
||||||
var thisTiddlerAssignment = {
|
|
||||||
type: "set",
|
|
||||||
attributes: {
|
|
||||||
name: {type: "string", value: "thisTiddler"},
|
|
||||||
value: {type: "string", value: options.title}
|
|
||||||
},
|
|
||||||
children: [],
|
|
||||||
doNotImport: true
|
|
||||||
};
|
|
||||||
topBranch.push(thisTiddlerAssignment);
|
|
||||||
topBranch = thisTiddlerAssignment.children;
|
|
||||||
}
|
|
||||||
// Parse any pragmas
|
// Parse any pragmas
|
||||||
topBranch = this.parsePragmas(topBranch);
|
var topBranch = this.parsePragmas();
|
||||||
// Parse the text into inline runs or blocks
|
// Parse the text into inline runs or blocks
|
||||||
if(this.parseAsInline) {
|
if(this.parseAsInline) {
|
||||||
topBranch.push.apply(topBranch,this.parseInlineRun());
|
topBranch.push.apply(topBranch,this.parseInlineRun());
|
||||||
@ -206,8 +190,8 @@ WikiParser.prototype.findNextMatch = function(rules,startPos) {
|
|||||||
/*
|
/*
|
||||||
Parse any pragmas at the beginning of a block of parse text
|
Parse any pragmas at the beginning of a block of parse text
|
||||||
*/
|
*/
|
||||||
WikiParser.prototype.parsePragmas = function(targetParseTreeNodes) {
|
WikiParser.prototype.parsePragmas = function() {
|
||||||
var currentTreeBranch = targetParseTreeNodes || this.tree;
|
var currentTreeBranch = this.tree;
|
||||||
while(true) {
|
while(true) {
|
||||||
// Skip whitespace
|
// Skip whitespace
|
||||||
this.skipWhitespace();
|
this.skipWhitespace();
|
||||||
|
@ -74,7 +74,7 @@ ImportVariablesWidget.prototype.execute = function(tiddlerList) {
|
|||||||
$tw.utils.each(Object.keys(widget.variables), function(key) {
|
$tw.utils.each(Object.keys(widget.variables), function(key) {
|
||||||
widgetPointer.variables[key] = widget.variables[key];
|
widgetPointer.variables[key] = widget.variables[key];
|
||||||
});
|
});
|
||||||
} else if(!parseTreeNode.doNotImport) {
|
} else {
|
||||||
widgetPointer.children = [widgetPointer.makeChildWidget(node)];
|
widgetPointer.children = [widgetPointer.makeChildWidget(node)];
|
||||||
// No more regenerating children for
|
// No more regenerating children for
|
||||||
// this widget. If it needs to refresh,
|
// this widget. If it needs to refresh,
|
||||||
|
@ -969,7 +969,6 @@ Parse a block of text of a specified MIME type
|
|||||||
Options include:
|
Options include:
|
||||||
parseAsInline: if true, the text of the tiddler will be parsed as an inline run
|
parseAsInline: if true, the text of the tiddler will be parsed as an inline run
|
||||||
_canonical_uri: optional string of the canonical URI of this content
|
_canonical_uri: optional string of the canonical URI of this content
|
||||||
title: optional tiddler title to be available within this parse tree via the variable "thisTiddler"
|
|
||||||
*/
|
*/
|
||||||
exports.parseText = function(type,text,options) {
|
exports.parseText = function(type,text,options) {
|
||||||
text = text || "";
|
text = text || "";
|
||||||
@ -989,8 +988,7 @@ exports.parseText = function(type,text,options) {
|
|||||||
return new Parser(type,text,{
|
return new Parser(type,text,{
|
||||||
parseAsInline: options.parseAsInline,
|
parseAsInline: options.parseAsInline,
|
||||||
wiki: this,
|
wiki: this,
|
||||||
_canonical_uri: options._canonical_uri,
|
_canonical_uri: options._canonical_uri
|
||||||
title: options.title
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -998,9 +996,7 @@ exports.parseText = function(type,text,options) {
|
|||||||
Parse a tiddler according to its MIME type
|
Parse a tiddler according to its MIME type
|
||||||
*/
|
*/
|
||||||
exports.parseTiddler = function(title,options) {
|
exports.parseTiddler = function(title,options) {
|
||||||
options = $tw.utils.extend({
|
options = $tw.utils.extend({},options);
|
||||||
title: title
|
|
||||||
},options);
|
|
||||||
var cacheType = options.parseAsInline ? "inlineParseTree" : "blockParseTree",
|
var cacheType = options.parseAsInline ? "inlineParseTree" : "blockParseTree",
|
||||||
tiddler = this.getTiddler(title),
|
tiddler = this.getTiddler(title),
|
||||||
self = this;
|
self = this;
|
||||||
@ -1013,9 +1009,6 @@ exports.parseTiddler = function(title,options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.parseTextReference = function(title,field,index,options) {
|
exports.parseTextReference = function(title,field,index,options) {
|
||||||
options = $tw.utils.extend({
|
|
||||||
title: title
|
|
||||||
},options);
|
|
||||||
var tiddler,
|
var tiddler,
|
||||||
text,
|
text,
|
||||||
parserInfo;
|
parserInfo;
|
||||||
@ -1117,7 +1110,6 @@ options.recursionMarker : optional flag to set a recursion marker, defaults to "
|
|||||||
options.children: optional array of children for the transclude widget
|
options.children: optional array of children for the transclude widget
|
||||||
options.importVariables: optional importvariables filter string for macros to be included
|
options.importVariables: optional importvariables filter string for macros to be included
|
||||||
options.importPageMacros: optional boolean; if true, equivalent to passing "[[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]" to options.importVariables
|
options.importPageMacros: optional boolean; if true, equivalent to passing "[[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]" to options.importVariables
|
||||||
options.title: optional tiddler title to be available within this parse tree via the variable "thisTiddler"
|
|
||||||
*/
|
*/
|
||||||
exports.makeTranscludeWidget = function(title,options) {
|
exports.makeTranscludeWidget = function(title,options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
@ -1182,7 +1174,6 @@ Parse text in a specified format and render it into another format
|
|||||||
Options include:
|
Options include:
|
||||||
variables: hashmap of variables to set
|
variables: hashmap of variables to set
|
||||||
parentWidget: optional parent widget for the root node
|
parentWidget: optional parent widget for the root node
|
||||||
title: optional tiddler title to be available within this parse tree via the variable "thisTiddler"
|
|
||||||
*/
|
*/
|
||||||
exports.renderText = function(outputType,textType,text,options) {
|
exports.renderText = function(outputType,textType,text,options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
Loading…
Reference in New Issue
Block a user