diff --git a/index.html b/index.html index 36089d5..92004ea 100644 --- a/index.html +++ b/index.html @@ -29,7 +29,8 @@ - + + diff --git a/node/blog.js b/node/blog.js index fc5441c..91ccbca 100644 --- a/node/blog.js +++ b/node/blog.js @@ -2,12 +2,14 @@ const { JSDOM } = require("jsdom"); const fs = require("fs"); -require("showdown-prettify"); + const showdown = require("showdown"); +require("../shared/showdown-prettify"); +require("../shared/showdown-footnotes"); const converter = new showdown.Converter({ parseImgDimensions: true, headerLevelStart: 3, - extensions: ["prettify"] + extensions: ["prettify", "footnotes"] }); module.exports = function () { diff --git a/node/rss.js b/node/rss.js index caffc55..ccfc516 100644 --- a/node/rss.js +++ b/node/rss.js @@ -2,9 +2,13 @@ const { Feed } = require("feed"); const fs = require("fs"); + const showdown = require("showdown"); +require("../shared/showdown-prettify"); +require("../shared/showdown-footnotes"); const converter = new showdown.Converter({ - parseImgDimensions: true + parseImgDimensions: true, + extensions: ["prettify", "footnotes"] }); module.exports = function () { diff --git a/scripts/blog.js b/scripts/blog.js index 39b05b3..ff65722 100644 --- a/scripts/blog.js +++ b/scripts/blog.js @@ -1,7 +1,7 @@ let converter = new showdown.Converter({ parseImgDimensions: true, headerLevelStart: 3, - extensions: ["prettify"] + extensions: ["prettify", "footnotes"] }); $.ajax({ dataType: "json", diff --git a/shared/showdown-footnotes.js b/shared/showdown-footnotes.js new file mode 100644 index 0000000..b699c99 --- /dev/null +++ b/shared/showdown-footnotes.js @@ -0,0 +1,46 @@ +// 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).+)+)$/mg, function (str, name, rawContent, _, padding) { + var content = converter.makeHtml(rawContent.replace(new RegExp('^' + padding, 'gm'), '')); + return '
[' + name + ']:' + content + '
'; + }); + } + }, { + type: 'lang', + filter: function filter(text) { + return text.replace(/^\[\^([\d\w]+)\]:( |\n)((.+\n)*.+)$/mg, function (str, name, _, content) { + return '[' + name + ']: ' + content + ''; + }); + } + }, { + type: 'lang', + filter: function filter(text) { + return text.replace(/\[\^([\d\w]+)\]/m, function (str, name) { + return '[' + name + ']'; + }); + } + }]; + }); +})); + +//# sourceMappingURL=showdown-prettify.js.map \ No newline at end of file diff --git a/scripts/showdown-prettify.js b/shared/showdown-prettify.js similarity index 89% rename from scripts/showdown-prettify.js rename to shared/showdown-prettify.js index 3e3a8e5..6e17c2c 100644 --- a/scripts/showdown-prettify.js +++ b/shared/showdown-prettify.js @@ -1,3 +1,5 @@ +// Modified version of https://github.com/showdownjs/prettify-extension + /*! showdown-prettify 06-01-2016 */ (function (extension) { 'use strict';