discourse/app/assets/javascripts/external/Markdown.Converter.js

50 lines
1.3 KiB
JavaScript
Raw Normal View History

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
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;
})();