Web/node/showdown-prettify.js

35 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-10-09 23:43:40 +02:00
// Modified version of https://github.com/showdownjs/prettify-extension
2019-10-03 15:15:25 +02:00
/*! showdown-prettify 06-01-2016 */
(function (extension) {
'use strict';
if (typeof showdown !== 'undefined') {
extension(showdown);
} else if (typeof define === 'function' && define.amd) {
define(['showdown'], extension);
} else if (typeof exports === 'object') {
module.exports = extension(require('showdown'));
} else {
throw Error('Could not find showdown library');
}
}(function (showdown) {
'use strict';
showdown.extension('prettify', function () {
return [{
type: 'output',
filter: function (source) {
return source.replace(/(<pre[^>]*>)?[\n\s]?<code([^>]*)>/gi, function (match, pre, codeClass) {
if (pre) {
return '<pre class="prettyprint linenums"><code' + codeClass + '>';
} else {
2019-10-03 23:07:39 +02:00
return ' <code>';
2019-10-03 15:15:25 +02:00
}
});
}
}];
});
}));
//# sourceMappingURL=showdown-prettify.js.map