From 6e07307f92bd44bd21607ac86a04108c72864f01 Mon Sep 17 00:00:00 2001 From: chris062689 Date: Fri, 2 Jun 2017 21:31:52 -0400 Subject: [PATCH] Restructed game content. --- scripts/games/blackfriday.js | 33 ++++++++++++++++++ .../images/games/{ => boxart}/default.png | Bin 2 files changed, 33 insertions(+) create mode 100644 scripts/games/blackfriday.js rename site/static/images/games/{ => boxart}/default.png (100%) diff --git a/scripts/games/blackfriday.js b/scripts/games/blackfriday.js new file mode 100644 index 0000000..c7ad8ca --- /dev/null +++ b/scripts/games/blackfriday.js @@ -0,0 +1,33 @@ +// Blackfriday markdown rendering requires a blank line before lists. +module.exports.fixLists = function(markdown) { + var lines = markdown.split(/\r?\n/); + for (var i = 0; i < lines.length; i++) { + // If it's the start of the file, ignore to prevent an index issue. + if (i > lines.length) { return; } + if (i == 0 || lines[i] == '\n') { continue; } + + // Search for the start of a list designated by the * character. + if (lines[i].startsWith("* ") && lines[i - 1].startsWith("* ") == false) { + i = i + 1; + lines.splice(i - 1, 0, ''); + } + } + + return lines.join('\r\n'); +} + +module.exports.fixLinks = function(markdown) { + let cleaned = markdown; + + // Replacing tags like [[Common Issues on Windows|Common Issues]] + cleaned = markdown.replace(/\[\[(.*)\|(.*)\]\]/g, function(match, p1, p2) { + return `[${p1}](${url(p2)})` + }); + + // Replacing tags like [[Common Issues]] + cleaned = markdown.replace(/\[\[(.*)\]\]/g, function(match, p1) { + return `[${p1}](${url(p1)})` + }); + + return cleaned; +} diff --git a/site/static/images/games/default.png b/site/static/images/games/boxart/default.png similarity index 100% rename from site/static/images/games/default.png rename to site/static/images/games/boxart/default.png