mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-26 19:04:37 +00:00
Major refactoring of how wiki text parsing and rendering is packaged
This commit is contained in:
30
js/WikiTextProcessor.js
Normal file
30
js/WikiTextProcessor.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/*jslint node: true */
|
||||
"use strict";
|
||||
|
||||
var WikiTextRules = require("./WikiTextRules.js"),
|
||||
WikiTextParser = require("./WikiTextParser.js").WikiTextParser;
|
||||
|
||||
|
||||
/*
|
||||
Creates a new instance of the wiki text processor with the specified options. The
|
||||
options are a hashmap of optional members as follows:
|
||||
|
||||
enableRules: An array of names of wiki text rules to enable. If not specified, all rules are available
|
||||
extraRules: An array of additional rule handlers to add
|
||||
enableMacros: An array of names of macros to enable. If not specified, all macros are available
|
||||
extraMacros: An array of additional macro handlers to add
|
||||
*/
|
||||
var WikiTextProcessor = function(options) {
|
||||
this.rules = WikiTextRules.rules;
|
||||
var pattern = [];
|
||||
for(var n=0; n<this.rules.length; n++) {
|
||||
pattern.push("(" + this.rules[n].match + ")");
|
||||
}
|
||||
this.rulesRegExp = new RegExp(pattern.join("|"),"mg");
|
||||
};
|
||||
|
||||
WikiTextProcessor.prototype.parse = function(text) {
|
||||
return new WikiTextParser(text,this);
|
||||
}
|
||||
|
||||
exports.WikiTextProcessor = WikiTextProcessor;
|
||||
Reference in New Issue
Block a user