1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-30 07:50:47 +00:00

Continuing renaming run rules to inline rules

This commit is contained in:
Jeremy Ruston 2012-12-20 12:18:38 +00:00
parent fc28ed0bbb
commit 360e188e49
21 changed files with 75 additions and 75 deletions

View File

@ -1,7 +1,7 @@
/*\ /*\
title: $:/core/modules/parsers/wikiparser/rules/block/classblock.js title: $:/core/modules/parsers/wikiparser/rules/block/classblock.js
type: application/javascript 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: Wiki text block rule for assigning classes to paragraphs and other blocks. For example:

View File

@ -1,7 +1,7 @@
/*\ /*\
title: $:/core/modules/parsers/wikiparser/rules/block/codeblock.js title: $:/core/modules/parsers/wikiparser/rules/block/codeblock.js
type: application/javascript type: application/javascript
module-type: wikiblockrule module-type: wiki-block-rule
Wiki text rule for code blocks. For example: Wiki text rule for code blocks. For example:

View File

@ -1,7 +1,7 @@
/*\ /*\
title: $:/core/modules/parsers/wikiparser/rules/block/heading.js title: $:/core/modules/parsers/wikiparser/rules/block/heading.js
type: application/javascript type: application/javascript
module-type: wikiblockrule module-type: wiki-block-rule
Wiki text block rule for headings Wiki text block rule for headings
@ -31,7 +31,7 @@ exports.parse = function() {
// Parse any classes, whitespace and then the heading itself // Parse any classes, whitespace and then the heading itself
var classes = this.parser.parseClasses(); var classes = this.parser.parseClasses();
this.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true}); 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 the heading
return [{ return [{
type: "element", type: "element",

View File

@ -1,7 +1,7 @@
/*\ /*\
title: $:/core/modules/parsers/wikiparser/rules/block/list.js title: $:/core/modules/parsers/wikiparser/rules/block/list.js
type: application/javascript type: application/javascript
module-type: wikiblockrule module-type: wiki-block-rule
Wiki text block rule for lists. For example: Wiki text block rule for lists. For example:
@ -114,7 +114,7 @@ exports.parse = function() {
lastListItem = lastListChildren[lastListChildren.length-1], lastListItem = lastListChildren[lastListChildren.length-1],
classes = this.parser.parseClasses(); classes = this.parser.parseClasses();
this.parser.skipWhitespace({treatNewlinesAsNonWhitespace: true}); 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); lastListItem.children.push.apply(lastListItem.children,tree);
if(classes.length > 0) { if(classes.length > 0) {
$tw.utils.addClassToParseTreeNode(lastListItem,classes.join(" ")); $tw.utils.addClassToParseTreeNode(lastListItem,classes.join(" "));

View File

@ -1,7 +1,7 @@
/*\ /*\
title: $:/core/modules/parsers/wikiparser/rules/block/rule.js title: $:/core/modules/parsers/wikiparser/rules/block/rule.js
type: application/javascript type: application/javascript
module-type: wikiblockrule module-type: wiki-block-rule
Wiki text block rule for rules. For example: Wiki text block rule for rules. For example:

View File

@ -1,7 +1,7 @@
/*\ /*\
title: $:/core/modules/parsers/wikiparser/rules/block/table.js title: $:/core/modules/parsers/wikiparser/rules/block/table.js
type: application/javascript type: application/javascript
module-type: wikiblockrule module-type: wiki-block-rule
Wiki text block rule for tables. Wiki text block rule for tables.
@ -86,7 +86,7 @@ var processRow = function(prevColumns) {
colSpanCount = 1; colSpanCount = 1;
} }
// Parse the cell // 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 // Set the alignment for the cell
if(cellMatch[1].substr(cellMatch[1].length-1,1) === " ") { // spaceRight if(cellMatch[1].substr(cellMatch[1].length-1,1) === " ") { // spaceRight
$tw.utils.addAttributeToParseTreeNode(cell,"align",spaceLeft ? "center" : "left"); $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 // Set the alignment - TODO: figure out why TW did this
// rowContainer.attributes.align = rowCount === 0 ? "top" : "bottom"; // rowContainer.attributes.align = rowCount === 0 ? "top" : "bottom";
// Parse the caption // Parse the caption
rowContainer.children = this.parser.parseRun(rowTermRegExp,{eatTerminator: true}); rowContainer.children = this.parser.parseInlineRun(rowTermRegExp,{eatTerminator: true});
} else { } else {
// Create the row // Create the row
var theRow = {type: "element", tag: "tr", children: []}; var theRow = {type: "element", tag: "tr", children: []};

View File

@ -1,7 +1,7 @@
/*\ /*\
title: $:/core/modules/parsers/wikiparser/rules/block/transcludeblock.js title: $:/core/modules/parsers/wikiparser/rules/block/transcludeblock.js
type: application/javascript type: application/javascript
module-type: wikiblockrule module-type: wiki-block-rule
Wiki text rule for block-level transclusion. For example: Wiki text rule for block-level transclusion. For example:

View File

@ -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 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`. {{myClass{This text will have the CSS class `myClass`.
@ -21,7 +21,7 @@ List item 2}}}
/*global $tw: false */ /*global $tw: false */
"use strict"; "use strict";
exports.name = "classrun"; exports.name = "classinline";
exports.init = function(parser) { exports.init = function(parser) {
this.parser = parser; this.parser = parser;
@ -36,7 +36,7 @@ exports.parse = function() {
// Move past the match // Move past the match
this.parser.pos = this.matchRegExp.lastIndex; this.parser.pos = this.matchRegExp.lastIndex;
// Parse the run up to the terminator // 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 the classed span
return [{ return [{
type: "element", type: "element",

View File

@ -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 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`. 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 */ /*global $tw: false */
"use strict"; "use strict";
exports.name = "coderun"; exports.name = "codeinline";
exports.init = function(parser) { exports.init = function(parser) {
this.parser = parser; this.parser = parser;

View File

@ -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 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 --> <!-- This is a comment -->

View File

@ -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 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: -- This is an en-dash: --

View File

@ -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 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 This is ''bold'' text
@ -66,7 +66,7 @@ exports.parse = function() {
break; break;
} }
// Parse the run including the terminator // 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 the classed span
return [{ return [{
type: "element", type: "element",

View File

@ -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 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: &copy; This is a copyright symbol: &copy;

View File

@ -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 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/ An external link: http://www.tiddlywiki.com/

View File

@ -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 type: application/javascript
module-type: wikirunrule module-type: wiki-inline-rule
Wiki rule for HTML elements and widgets. For example: Wiki rule for HTML elements and widgets. For example:
@ -83,7 +83,7 @@ exports.parse = function() {
if(isBlock) { if(isBlock) {
content = this.parser.parseBlocks(reEndString); content = this.parser.parseBlocks(reEndString);
} else { } else {
content = this.parser.parseRun(reEnd); content = this.parser.parseInlineRun(reEnd);
} }
reEnd.lastIndex = this.parser.pos; reEnd.lastIndex = this.parser.pos;
var endMatch = reEnd.exec(this.parser.source); var endMatch = reEnd.exec(this.parser.source);

View File

@ -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 type: application/javascript
module-type: wikirunrule module-type: wiki-inline-rule
Wiki rule for macro calls Wiki rule for macro calls

View File

@ -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 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]] [[Introduction]]

View File

@ -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 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 AWikiLink

View File

@ -1,7 +1,7 @@
/*\ /*\
title: $:/core/modules/parsers/wikiparser/rules/pragma/macrodef.js title: $:/core/modules/parsers/wikiparser/rules/pragma/macrodef.js
type: application/javascript type: application/javascript
module-type: wikipragmarule module-type: wiki-pragma-rule
Wiki pragma rule for macro definitions Wiki pragma rule for macro definitions

View File

@ -41,12 +41,12 @@ var WikiParser = function(vocabulary,type,text,options) {
this.pragmaRules = this.instantiateRules(this.vocabulary.pragmaRuleClasses,0); this.pragmaRules = this.instantiateRules(this.vocabulary.pragmaRuleClasses,0);
// Parse any pragmas // Parse any pragmas
this.parsePragmas(); 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.blockRules = this.instantiateRules(this.vocabulary.blockRuleClasses,this.pos);
this.runRules = this.instantiateRules(this.vocabulary.runRuleClasses,this.pos); this.inlineRules = this.instantiateRules(this.vocabulary.inlineRuleClasses,this.pos);
// Parse the text into runs or blocks // Parse the text into inline runs or blocks
if(this.type === "text/vnd.tiddlywiki-run") { if(this.type === "text/vnd.tiddlywiki-run") {
this.tree = this.parseRun(); this.tree = this.parseInlineRun();
} else { } else {
this.tree = this.parseBlocks(); this.tree = this.parseBlocks();
} }
@ -148,7 +148,7 @@ WikiParser.prototype.parseBlock = function(terminatorRegExpString) {
return nextMatch.rule.parse(); return nextMatch.rule.parse();
} }
// Treat it as a paragraph if we didn't find a block rule // 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: Options available:
eatTerminator: move the parse position past any encountered terminator (default false) 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) { if(terminatorRegExp) {
return this.parseRunTerminated(terminatorRegExp,options); return this.parseInlineRunTerminated(terminatorRegExp,options);
} else { } else {
return this.parseRunUnterminated(options); return this.parseInlineRunUnterminated(options);
} }
}; };
WikiParser.prototype.parseRunUnterminated = function(options) { WikiParser.prototype.parseInlineRunUnterminated = function(options) {
var tree = []; var tree = [];
// Find the next occurrence of a runrule // Find the next occurrence of a runrule
var nextMatch = this.findNextMatch(this.runRules,this.pos); var nextMatch = this.findNextMatch(this.runRules,this.pos);
@ -240,19 +240,19 @@ WikiParser.prototype.parseRunUnterminated = function(options) {
return tree; return tree;
}; };
WikiParser.prototype.parseRunTerminated = function(terminatorRegExp,options) { WikiParser.prototype.parseInlineRunTerminated = function(terminatorRegExp,options) {
options = options || {}; options = options || {};
var tree = []; var tree = [];
// Find the next occurrence of the terminator // Find the next occurrence of the terminator
terminatorRegExp.lastIndex = this.pos; terminatorRegExp.lastIndex = this.pos;
var terminatorMatch = terminatorRegExp.exec(this.source); var terminatorMatch = terminatorRegExp.exec(this.source);
// Find the next occurrence of a runrule // Find the next occurrence of a inlinerule
var runRuleMatch = this.findNextMatch(this.runRules,this.pos); var inlineRuleMatch = this.findNextMatch(this.inlineRules,this.pos);
// Loop around until we've reached the end of the text // Loop around until we've reached the end of the text
while(this.pos < this.sourceLength && (terminatorMatch || runRuleMatch)) { while(this.pos < this.sourceLength && (terminatorMatch || inlineRuleMatch)) {
// Return if we've found the terminator, and it precedes any run rule match // Return if we've found the terminator, and it precedes any inline rule match
if(terminatorMatch) { if(terminatorMatch) {
if(!runRuleMatch || runRuleMatch.matchIndex >= terminatorMatch.index) { if(!inlineRuleMatch || inlineRuleMatch.matchIndex >= terminatorMatch.index) {
if(terminatorMatch.index > this.pos) { if(terminatorMatch.index > this.pos) {
tree.push({type: "text", text: this.source.substring(this.pos,terminatorMatch.index)}); tree.push({type: "text", text: this.source.substring(this.pos,terminatorMatch.index)});
} }
@ -263,17 +263,17 @@ WikiParser.prototype.parseRunTerminated = function(terminatorRegExp,options) {
return tree; return tree;
} }
} }
// Process any run rule, along with the text preceding it // Process any inline rule, along with the text preceding it
if(runRuleMatch) { if(inlineRuleMatch) {
// Preceding text // Preceding text
if(runRuleMatch.matchIndex > this.pos) { if(inlineRuleMatch.matchIndex > this.pos) {
tree.push({type: "text", text: this.source.substring(this.pos,runRuleMatch.matchIndex)}); tree.push({type: "text", text: this.source.substring(this.pos,inlineRuleMatch.matchIndex)});
this.pos = runRuleMatch.matchIndex; this.pos = inlineRuleMatch.matchIndex;
} }
// Process the run rule // Process the inline rule
tree.push.apply(tree,runRuleMatch.rule.parse()); tree.push.apply(tree,inlineRuleMatch.rule.parse());
// Look for the next run rule // Look for the next inline rule
runRuleMatch = this.findNextMatch(this.runRules,this.pos); inlineRuleMatch = this.findNextMatch(this.inlineRules,this.pos);
// Look for the next terminator match // Look for the next terminator match
terminatorRegExp.lastIndex = this.pos; terminatorRegExp.lastIndex = this.pos;
terminatorMatch = terminatorRegExp.exec(this.source); terminatorMatch = terminatorRegExp.exec(this.source);

View File

@ -13,9 +13,9 @@ module-type: global
var WikiVocabulary = function(options) { var WikiVocabulary = function(options) {
this.wiki = options.wiki; this.wiki = options.wiki;
// Hashmaps of the various parse rule classes // Hashmaps of the various parse rule classes
this.pragmaRuleClasses = $tw.modules.createClassesFromModules("wikipragmarule",$tw.WikiRuleBase); this.pragmaRuleClasses = $tw.modules.createClassesFromModules("wiki-pragma-rule",$tw.WikiRuleBase);
this.blockRuleClasses = $tw.modules.createClassesFromModules("wikiblockrule",$tw.WikiRuleBase); this.blockRuleClasses = $tw.modules.createClassesFromModules("wiki-block-rule",$tw.WikiRuleBase);
this.runRuleClasses = $tw.modules.createClassesFromModules("wikirunrule",$tw.WikiRuleBase); this.inlineRuleClasses = $tw.modules.createClassesFromModules("wiki-inline-rule",$tw.WikiRuleBase);
// Hashmap of the various renderer classes // Hashmap of the various renderer classes
this.rendererClasses = $tw.modules.applyMethods("wikirenderer"); this.rendererClasses = $tw.modules.applyMethods("wikirenderer");
// Hashmap of the available widgets // Hashmap of the available widgets