2013-02-05 14:16:51 -05:00
|
|
|
var Markdown;
|
|
|
|
|
|
|
|
if (typeof exports === "object" && typeof require === "function") // we're in a CommonJS (e.g. Node.js) module
|
2013-08-08 18:14:12 -04:00
|
|
|
Markdown = exports;
|
2013-02-05 14:16:51 -05:00
|
|
|
else
|
2013-08-08 18:14:12 -04:00
|
|
|
Markdown = {};
|
2013-02-05 14:16:51 -05:00
|
|
|
|
2013-08-08 18:14:12 -04:00
|
|
|
/**
|
|
|
|
This is only included so we have an interface that Pagedown can use.
|
|
|
|
**/
|
2013-02-05 14:16:51 -05:00
|
|
|
(function () {
|
|
|
|
|
|
|
|
function identity(x) { return x; }
|
|
|
|
function returnFalse(x) { return false; }
|
|
|
|
|
|
|
|
function HookCollection() { }
|
|
|
|
|
|
|
|
HookCollection.prototype = {
|
|
|
|
|
|
|
|
chain: function (hookname, func) {
|
|
|
|
var original = this[hookname];
|
|
|
|
if (!original)
|
|
|
|
throw new Error("unknown hook " + hookname);
|
|
|
|
|
|
|
|
if (original === identity)
|
|
|
|
this[hookname] = func;
|
|
|
|
else
|
2013-02-24 07:40:06 -05:00
|
|
|
this[hookname] = function (text) {
|
|
|
|
var args = Array.prototype.slice.call(arguments, 0);
|
|
|
|
args[0] = original.apply(null, args);
|
|
|
|
return func.apply(null, args);
|
|
|
|
};
|
2013-02-05 14:16:51 -05:00
|
|
|
},
|
|
|
|
set: function (hookname, func) {
|
|
|
|
if (!this[hookname])
|
|
|
|
throw new Error("unknown hook " + hookname);
|
|
|
|
this[hookname] = func;
|
|
|
|
},
|
|
|
|
addNoop: function (hookname) {
|
|
|
|
this[hookname] = identity;
|
|
|
|
},
|
|
|
|
addFalse: function (hookname) {
|
|
|
|
this[hookname] = returnFalse;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Markdown.HookCollection = HookCollection;
|
|
|
|
|
|
|
|
})();
|