2012-12-14 13:31:47 +00:00
|
|
|
/*\
|
2012-12-14 17:38:46 +00:00
|
|
|
title: $:/core/modules/parsers/wikiparser/rules/wikirulebase.js
|
2012-12-14 13:31:47 +00:00
|
|
|
type: application/javascript
|
|
|
|
module-type: global
|
|
|
|
|
|
|
|
Base class for wiki parser rules
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
2012-12-14 15:44:19 +00:00
|
|
|
/*
|
|
|
|
This constructor is always overridden with a blank constructor, and so shouldn't be used
|
|
|
|
*/
|
2012-12-14 17:38:46 +00:00
|
|
|
var WikiRuleBase = function() {
|
2012-12-14 15:44:19 +00:00
|
|
|
};
|
2012-12-14 13:31:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
To be overridden by individual rules
|
|
|
|
*/
|
2012-12-14 17:38:46 +00:00
|
|
|
WikiRuleBase.prototype.init = function(parser) {
|
2012-12-14 15:44:19 +00:00
|
|
|
this.parser = parser;
|
2012-12-14 13:31:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2012-12-14 15:44:19 +00:00
|
|
|
Default implementation of findNextMatch uses RegExp matching
|
2012-12-14 13:31:47 +00:00
|
|
|
*/
|
2012-12-14 17:38:46 +00:00
|
|
|
WikiRuleBase.prototype.findNextMatch = function(startPos) {
|
2012-12-14 13:31:47 +00:00
|
|
|
this.matchRegExp.lastIndex = startPos;
|
|
|
|
this.match = this.matchRegExp.exec(this.parser.source);
|
|
|
|
return this.match ? this.match.index : undefined;
|
|
|
|
};
|
|
|
|
|
2012-12-14 17:38:46 +00:00
|
|
|
exports.WikiRuleBase = WikiRuleBase;
|
2012-12-14 13:31:47 +00:00
|
|
|
|
|
|
|
})();
|