mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-04-30 18:26:47 +00:00
Major refactoring of how wiki text parsing and rendering is packaged
This commit is contained in:
26
js/TextProcessors.js
Normal file
26
js/TextProcessors.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/*jslint node: true */
|
||||
"use strict";
|
||||
|
||||
var util = require("util");
|
||||
|
||||
var TextProcessors = function() {
|
||||
this.processors = {};
|
||||
};
|
||||
|
||||
TextProcessors.prototype.registerTextProcessor = function(type,processor) {
|
||||
this.processors[type] = processor;
|
||||
};
|
||||
|
||||
TextProcessors.prototype.parse = function(type,text) {
|
||||
var processor = this.processors[type];
|
||||
if(!processor) {
|
||||
processor = this.processors["text/x-tiddlywiki"];
|
||||
}
|
||||
if(processor) {
|
||||
return processor.parse(text);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
exports.TextProcessors = TextProcessors;
|
||||
Reference in New Issue
Block a user