marked/test/browser/test.js

65 lines
1.2 KiB
JavaScript
Raw Normal View History

;(function() {
2013-01-06 21:43:11 -06:00
var console = {}
, files = __TESTS__;
2013-01-06 21:43:11 -06:00
console.log = function(text) {
var args = Array.prototype.slice.call(arguments, 1)
, i = 0;
text = text.replace(/%\w/g, function() {
return args[i++] || '';
});
if (window.console) window.console.log(text);
document.body.innerHTML += '<pre>' + escape(text) + '</pre>';
2013-01-06 21:43:11 -06:00
};
if (!Object.keys) {
Object.keys = function(obj) {
var out = []
, key;
for (key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
out.push(key);
}
}
return out;
};
}
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(callback, context) {
for (var i = 0; i < this.length; i++) {
callback.call(context || null, this[i], i, obj);
}
};
}
if (!String.prototype.trim) {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
};
}
2013-02-13 16:20:28 -06:00
function load() {
return files;
}
2013-01-06 21:43:11 -06:00
2013-01-03 08:29:40 -06:00
function escape(html, encode) {
return html
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
2013-01-03 08:29:40 -06:00
}
__LIBS__;
2013-01-03 08:29:40 -06:00
(__MAIN__)();
}).call(this);