discourse/vendor/assets/javascripts/Markdown.Converter.js
2013-10-01 11:16:27 -04:00

49 lines
1.3 KiB
JavaScript

var Markdown;
if (typeof exports === "object" && typeof require === "function") // we're in a CommonJS (e.g. Node.js) module
Markdown = exports;
else
Markdown = {};
/**
This is only included so we have an interface that Pagedown can use.
**/
(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
this[hookname] = function (text) {
var args = Array.prototype.slice.call(arguments, 0);
args[0] = original.apply(null, args);
return func.apply(null, args);
};
},
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;
})();