Web/node/lib/showdown-prettify.js
Ell ee5c7b64f0
All checks were successful
Web/pipeline/head This commit looks good
overhauled most of the script code
2021-03-19 07:55:18 +01:00

35 lines
No EOL
1.1 KiB
JavaScript

// Modified version of https://github.com/showdownjs/prettify-extension
/*! 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 {
return ' <code>';
}
});
}
}];
});
}));
//# sourceMappingURL=showdown-prettify.js.map