46 lines
No EOL
1.9 KiB
JavaScript
46 lines
No EOL
1.9 KiB
JavaScript
// Modified version of https://github.com/Kriegslustig/showdown-footnotes
|
|
|
|
/*! 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('footnotes', function () {
|
|
return [{
|
|
type: 'lang',
|
|
filter: function filter(text) {
|
|
return text.replace(/\[\^([\d\w]+)\]:\s*((\n+(\s{2,4}|\t).+)+)/mgi, function (str, name, rawContent, _, padding) {
|
|
let content = converter.makeHtml(rawContent.replace(new RegExp(`^${padding}`, 'gm'), ''));
|
|
return `<a class="blog-anchor" id="footnote-${name}"></a><div class="footnote">[${name}]:${content}</div>`;
|
|
});
|
|
}
|
|
}, {
|
|
type: 'lang',
|
|
filter: function filter(text) {
|
|
return text.replace(/\[\^([\d\w]+)\]:( |\n)((.+\n)*.+)/mgi, function (str, name, _, content) {
|
|
return `<a class="blog-anchor" id="footnote-${name}"></a><small class="footnote"><a href="#footnote-reference-${name}">[${name}]</a>: ${content}</small>`;
|
|
});
|
|
}
|
|
}, {
|
|
type: 'lang',
|
|
filter: function filter(text) {
|
|
return text.replace(/\[\^([\d\w]+)\]/mgi, function (str, name) {
|
|
return `<a class="blog-anchor" id="footnote-reference-${name}"><a href="#footnote-${name}"><sup>[${name}]</sup></a>`;
|
|
});
|
|
}
|
|
}];
|
|
});
|
|
}));
|
|
|
|
//# sourceMappingURL=showdown-prettify.js.map
|