kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Continuing renaming run rules to inline rules
rodzic
fc28ed0bbb
commit
360e188e49
|
@ -1,7 +1,7 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/block/classblock.js
|
||||
type: application/javascript
|
||||
module-type: wikiblockrule
|
||||
module-type: wiki-block-rule
|
||||
|
||||
Wiki text block rule for assigning classes to paragraphs and other blocks. For example:
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/block/codeblock.js
|
||||
type: application/javascript
|
||||
module-type: wikiblockrule
|
||||
module-type: wiki-block-rule
|
||||
|
||||
Wiki text rule for code blocks. For example:
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/block/heading.js
|
||||
type: application/javascript
|
||||
module-type: wikiblockrule
|
||||
module-type: wiki-block-rule
|
||||
|
||||
Wiki text block rule for headings
|
||||
|
||||
|
@ -31,7 +31,7 @@ exports.parse = function() {
|
|||
// Parse any classes, whitespace and then the heading itself
|
||||
var classes = this.parser.parseClasses();
|
||||
this.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true});
|
||||
var tree = this.parser.parseRun(/(\r?\n)/mg);
|
||||
var tree = this.parser.parseInlineRun(/(\r?\n)/mg);
|
||||
// Return the heading
|
||||
return [{
|
||||
type: "element",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/block/list.js
|
||||
type: application/javascript
|
||||
module-type: wikiblockrule
|
||||
module-type: wiki-block-rule
|
||||
|
||||
Wiki text block rule for lists. For example:
|
||||
|
||||
|
@ -114,7 +114,7 @@ exports.parse = function() {
|
|||
lastListItem = lastListChildren[lastListChildren.length-1],
|
||||
classes = this.parser.parseClasses();
|
||||
this.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true});
|
||||
var tree = this.parser.parseRun(/(\r?\n)/mg);
|
||||
var tree = this.parser.parseInlineRun(/(\r?\n)/mg);
|
||||
lastListItem.children.push.apply(lastListItem.children,tree);
|
||||
if(classes.length > 0) {
|
||||
$tw.utils.addClassToParseTreeNode(lastListItem,classes.join(" "));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/block/rule.js
|
||||
type: application/javascript
|
||||
module-type: wikiblockrule
|
||||
module-type: wiki-block-rule
|
||||
|
||||
Wiki text block rule for rules. For example:
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/block/table.js
|
||||
type: application/javascript
|
||||
module-type: wikiblockrule
|
||||
module-type: wiki-block-rule
|
||||
|
||||
Wiki text block rule for tables.
|
||||
|
||||
|
@ -86,7 +86,7 @@ var processRow = function(prevColumns) {
|
|||
colSpanCount = 1;
|
||||
}
|
||||
// Parse the cell
|
||||
cell.children = this.parser.parseRun(cellTermRegExp,{eatTerminator: true});
|
||||
cell.children = this.parser.parseInlineRun(cellTermRegExp,{eatTerminator: true});
|
||||
// Set the alignment for the cell
|
||||
if(cellMatch[1].substr(cellMatch[1].length-1,1) === " ") { // spaceRight
|
||||
$tw.utils.addAttributeToParseTreeNode(cell,"align",spaceLeft ? "center" : "left");
|
||||
|
@ -140,7 +140,7 @@ exports.parse = function() {
|
|||
// Set the alignment - TODO: figure out why TW did this
|
||||
// rowContainer.attributes.align = rowCount === 0 ? "top" : "bottom";
|
||||
// Parse the caption
|
||||
rowContainer.children = this.parser.parseRun(rowTermRegExp,{eatTerminator: true});
|
||||
rowContainer.children = this.parser.parseInlineRun(rowTermRegExp,{eatTerminator: true});
|
||||
} else {
|
||||
// Create the row
|
||||
var theRow = {type: "element", tag: "tr", children: []};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/block/transcludeblock.js
|
||||
type: application/javascript
|
||||
module-type: wikiblockrule
|
||||
module-type: wiki-block-rule
|
||||
|
||||
Wiki text rule for block-level transclusion. For example:
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/run/classrun.js
|
||||
title: $:/core/modules/parsers/wikiparser/rules/inline/classinline.js
|
||||
type: application/javascript
|
||||
module-type: wikirunrule
|
||||
module-type: wiki-inline-rule
|
||||
|
||||
Wiki text run rule for assigning classes to runs of text. For example:
|
||||
Wiki text inline rule for assigning classes to runs of text. For example:
|
||||
|
||||
{{{
|
||||
{{myClass{This text will have the CSS class `myClass`.
|
||||
|
@ -21,7 +21,7 @@ List item 2}}}
|
|||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
exports.name = "classrun";
|
||||
exports.name = "classinline";
|
||||
|
||||
exports.init = function(parser) {
|
||||
this.parser = parser;
|
||||
|
@ -36,7 +36,7 @@ exports.parse = function() {
|
|||
// Move past the match
|
||||
this.parser.pos = this.matchRegExp.lastIndex;
|
||||
// Parse the run up to the terminator
|
||||
var tree = this.parser.parseRun(reEnd,{eatTerminator: true});
|
||||
var tree = this.parser.parseInlineRun(reEnd,{eatTerminator: true});
|
||||
// Return the classed span
|
||||
return [{
|
||||
type: "element",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/run/coderun.js
|
||||
title: $:/core/modules/parsers/wikiparser/rules/inline/codeinline.js
|
||||
type: application/javascript
|
||||
module-type: wikirunrule
|
||||
module-type: wiki-inline-rule
|
||||
|
||||
Wiki text run rule for code runs. For example:
|
||||
Wiki text inline rule for code runs. For example:
|
||||
|
||||
{{{
|
||||
This is a {{{code run}}} and `so is this`.
|
||||
|
@ -16,7 +16,7 @@ Wiki text run rule for code runs. For example:
|
|||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
exports.name = "coderun";
|
||||
exports.name = "codeinline";
|
||||
|
||||
exports.init = function(parser) {
|
||||
this.parser = parser;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/run/comment.js
|
||||
title: $:/core/modules/parsers/wikiparser/rules/inline/comment.js
|
||||
type: application/javascript
|
||||
module-type: wikirunrule
|
||||
module-type: wiki-inline-rule
|
||||
|
||||
Wiki text run rule for HTML comments. For example:
|
||||
Wiki text inline rule for HTML comments. For example:
|
||||
|
||||
{{{
|
||||
<!-- This is a comment -->
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/run/dash.js
|
||||
title: $:/core/modules/parsers/wikiparser/rules/inline/dash.js
|
||||
type: application/javascript
|
||||
module-type: wikirunrule
|
||||
module-type: wiki-inline-rule
|
||||
|
||||
Wiki text run rule for dashes. For example:
|
||||
Wiki text inline rule for dashes. For example:
|
||||
|
||||
{{{
|
||||
This is an en-dash: --
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/run/emphasis.js
|
||||
title: $:/core/modules/parsers/wikiparser/rules/inline/emphasis.js
|
||||
type: application/javascript
|
||||
module-type: wikirunrule
|
||||
module-type: wiki-inline-rule
|
||||
|
||||
Wiki text run rule for emphasis. For example:
|
||||
Wiki text inline rule for emphasis. For example:
|
||||
|
||||
{{{
|
||||
This is ''bold'' text
|
||||
|
@ -66,7 +66,7 @@ exports.parse = function() {
|
|||
break;
|
||||
}
|
||||
// Parse the run including the terminator
|
||||
var tree = this.parser.parseRun(reEnd,{eatTerminator: true});
|
||||
var tree = this.parser.parseInlineRun(reEnd,{eatTerminator: true});
|
||||
// Return the classed span
|
||||
return [{
|
||||
type: "element",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/run/entity.js
|
||||
title: $:/core/modules/parsers/wikiparser/rules/inline/entity.js
|
||||
type: application/javascript
|
||||
module-type: wikirunrule
|
||||
module-type: wiki-inline-rule
|
||||
|
||||
Wiki text run rule for HTML entities. For example:
|
||||
Wiki text inline rule for HTML entities. For example:
|
||||
|
||||
{{{
|
||||
This is a copyright symbol: ©
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/run/extlink.js
|
||||
title: $:/core/modules/parsers/wikiparser/rules/inline/extlink.js
|
||||
type: application/javascript
|
||||
module-type: wikirunrule
|
||||
module-type: wiki-inline-rule
|
||||
|
||||
Wiki text run rule for external links. For example:
|
||||
Wiki text inline rule for external links. For example:
|
||||
|
||||
{{{
|
||||
An external link: http://www.tiddlywiki.com/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/run/html.js
|
||||
title: $:/core/modules/parsers/wikiparser/rules/inline/html.js
|
||||
type: application/javascript
|
||||
module-type: wikirunrule
|
||||
module-type: wiki-inline-rule
|
||||
|
||||
Wiki rule for HTML elements and widgets. For example:
|
||||
|
||||
|
@ -83,7 +83,7 @@ exports.parse = function() {
|
|||
if(isBlock) {
|
||||
content = this.parser.parseBlocks(reEndString);
|
||||
} else {
|
||||
content = this.parser.parseRun(reEnd);
|
||||
content = this.parser.parseInlineRun(reEnd);
|
||||
}
|
||||
reEnd.lastIndex = this.parser.pos;
|
||||
var endMatch = reEnd.exec(this.parser.source);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/run/macrocall.js
|
||||
title: $:/core/modules/parsers/wikiparser/rules/inline/macrocall.js
|
||||
type: application/javascript
|
||||
module-type: wikirunrule
|
||||
module-type: wiki-inline-rule
|
||||
|
||||
Wiki rule for macro calls
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/run/prettylink.js
|
||||
title: $:/core/modules/parsers/wikiparser/rules/inline/prettylink.js
|
||||
type: application/javascript
|
||||
module-type: wikirunrule
|
||||
module-type: wiki-inline-rule
|
||||
|
||||
Wiki text run rule for pretty links. For example:
|
||||
Wiki text inline rule for pretty links. For example:
|
||||
|
||||
{{{
|
||||
[[Introduction]]
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/run/wikilink.js
|
||||
title: $:/core/modules/parsers/wikiparser/rules/inline/wikilink.js
|
||||
type: application/javascript
|
||||
module-type: wikirunrule
|
||||
module-type: wiki-inline-rule
|
||||
|
||||
Wiki text run rule for wiki links. For example:
|
||||
Wiki text inline rule for wiki links. For example:
|
||||
|
||||
{{{
|
||||
AWikiLink
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/pragma/macrodef.js
|
||||
type: application/javascript
|
||||
module-type: wikipragmarule
|
||||
module-type: wiki-pragma-rule
|
||||
|
||||
Wiki pragma rule for macro definitions
|
||||
|
||||
|
|
|
@ -41,12 +41,12 @@ var WikiParser = function(vocabulary,type,text,options) {
|
|||
this.pragmaRules = this.instantiateRules(this.vocabulary.pragmaRuleClasses,0);
|
||||
// Parse any pragmas
|
||||
this.parsePragmas();
|
||||
// Instantiate the parser block and run rules
|
||||
// Instantiate the parser block and inline rules
|
||||
this.blockRules = this.instantiateRules(this.vocabulary.blockRuleClasses,this.pos);
|
||||
this.runRules = this.instantiateRules(this.vocabulary.runRuleClasses,this.pos);
|
||||
// Parse the text into runs or blocks
|
||||
this.inlineRules = this.instantiateRules(this.vocabulary.inlineRuleClasses,this.pos);
|
||||
// Parse the text into inline runs or blocks
|
||||
if(this.type === "text/vnd.tiddlywiki-run") {
|
||||
this.tree = this.parseRun();
|
||||
this.tree = this.parseInlineRun();
|
||||
} else {
|
||||
this.tree = this.parseBlocks();
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ WikiParser.prototype.parseBlock = function(terminatorRegExpString) {
|
|||
return nextMatch.rule.parse();
|
||||
}
|
||||
// Treat it as a paragraph if we didn't find a block rule
|
||||
return [{type: "element", tag: "p", children: this.parseRun(terminatorRegExp)}];
|
||||
return [{type: "element", tag: "p", children: this.parseInlineRun(terminatorRegExp)}];
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -208,15 +208,15 @@ Parse a run of text at the current position
|
|||
Options available:
|
||||
eatTerminator: move the parse position past any encountered terminator (default false)
|
||||
*/
|
||||
WikiParser.prototype.parseRun = function(terminatorRegExp,options) {
|
||||
WikiParser.prototype.parseInlineRun = function(terminatorRegExp,options) {
|
||||
if(terminatorRegExp) {
|
||||
return this.parseRunTerminated(terminatorRegExp,options);
|
||||
return this.parseInlineRunTerminated(terminatorRegExp,options);
|
||||
} else {
|
||||
return this.parseRunUnterminated(options);
|
||||
return this.parseInlineRunUnterminated(options);
|
||||
}
|
||||
};
|
||||
|
||||
WikiParser.prototype.parseRunUnterminated = function(options) {
|
||||
WikiParser.prototype.parseInlineRunUnterminated = function(options) {
|
||||
var tree = [];
|
||||
// Find the next occurrence of a runrule
|
||||
var nextMatch = this.findNextMatch(this.runRules,this.pos);
|
||||
|
@ -240,19 +240,19 @@ WikiParser.prototype.parseRunUnterminated = function(options) {
|
|||
return tree;
|
||||
};
|
||||
|
||||
WikiParser.prototype.parseRunTerminated = function(terminatorRegExp,options) {
|
||||
WikiParser.prototype.parseInlineRunTerminated = function(terminatorRegExp,options) {
|
||||
options = options || {};
|
||||
var tree = [];
|
||||
// Find the next occurrence of the terminator
|
||||
terminatorRegExp.lastIndex = this.pos;
|
||||
var terminatorMatch = terminatorRegExp.exec(this.source);
|
||||
// Find the next occurrence of a runrule
|
||||
var runRuleMatch = this.findNextMatch(this.runRules,this.pos);
|
||||
// Find the next occurrence of a inlinerule
|
||||
var inlineRuleMatch = this.findNextMatch(this.inlineRules,this.pos);
|
||||
// Loop around until we've reached the end of the text
|
||||
while(this.pos < this.sourceLength && (terminatorMatch || runRuleMatch)) {
|
||||
// Return if we've found the terminator, and it precedes any run rule match
|
||||
while(this.pos < this.sourceLength && (terminatorMatch || inlineRuleMatch)) {
|
||||
// Return if we've found the terminator, and it precedes any inline rule match
|
||||
if(terminatorMatch) {
|
||||
if(!runRuleMatch || runRuleMatch.matchIndex >= terminatorMatch.index) {
|
||||
if(!inlineRuleMatch || inlineRuleMatch.matchIndex >= terminatorMatch.index) {
|
||||
if(terminatorMatch.index > this.pos) {
|
||||
tree.push({type: "text", text: this.source.substring(this.pos,terminatorMatch.index)});
|
||||
}
|
||||
|
@ -263,17 +263,17 @@ WikiParser.prototype.parseRunTerminated = function(terminatorRegExp,options) {
|
|||
return tree;
|
||||
}
|
||||
}
|
||||
// Process any run rule, along with the text preceding it
|
||||
if(runRuleMatch) {
|
||||
// Process any inline rule, along with the text preceding it
|
||||
if(inlineRuleMatch) {
|
||||
// Preceding text
|
||||
if(runRuleMatch.matchIndex > this.pos) {
|
||||
tree.push({type: "text", text: this.source.substring(this.pos,runRuleMatch.matchIndex)});
|
||||
this.pos = runRuleMatch.matchIndex;
|
||||
if(inlineRuleMatch.matchIndex > this.pos) {
|
||||
tree.push({type: "text", text: this.source.substring(this.pos,inlineRuleMatch.matchIndex)});
|
||||
this.pos = inlineRuleMatch.matchIndex;
|
||||
}
|
||||
// Process the run rule
|
||||
tree.push.apply(tree,runRuleMatch.rule.parse());
|
||||
// Look for the next run rule
|
||||
runRuleMatch = this.findNextMatch(this.runRules,this.pos);
|
||||
// Process the inline rule
|
||||
tree.push.apply(tree,inlineRuleMatch.rule.parse());
|
||||
// Look for the next inline rule
|
||||
inlineRuleMatch = this.findNextMatch(this.inlineRules,this.pos);
|
||||
// Look for the next terminator match
|
||||
terminatorRegExp.lastIndex = this.pos;
|
||||
terminatorMatch = terminatorRegExp.exec(this.source);
|
||||
|
|
|
@ -13,9 +13,9 @@ module-type: global
|
|||
var WikiVocabulary = function(options) {
|
||||
this.wiki = options.wiki;
|
||||
// Hashmaps of the various parse rule classes
|
||||
this.pragmaRuleClasses = $tw.modules.createClassesFromModules("wikipragmarule",$tw.WikiRuleBase);
|
||||
this.blockRuleClasses = $tw.modules.createClassesFromModules("wikiblockrule",$tw.WikiRuleBase);
|
||||
this.runRuleClasses = $tw.modules.createClassesFromModules("wikirunrule",$tw.WikiRuleBase);
|
||||
this.pragmaRuleClasses = $tw.modules.createClassesFromModules("wiki-pragma-rule",$tw.WikiRuleBase);
|
||||
this.blockRuleClasses = $tw.modules.createClassesFromModules("wiki-block-rule",$tw.WikiRuleBase);
|
||||
this.inlineRuleClasses = $tw.modules.createClassesFromModules("wiki-inline-rule",$tw.WikiRuleBase);
|
||||
// Hashmap of the various renderer classes
|
||||
this.rendererClasses = $tw.modules.applyMethods("wikirenderer");
|
||||
// Hashmap of the available widgets
|
||||
|
|
Ładowanie…
Reference in New Issue