From b339df0b61065bd21e06088c0f465648d3836b05 Mon Sep 17 00:00:00 2001 From: Eric Cornelissen Date: Mon, 10 Sep 2018 17:53:59 +0200 Subject: [PATCH] Update filemapping, ampersand (#977) * Replace ampersand to avoid problems with filenames Together with some examples as test * Revert filename changes for testing purposes --- index.html | 16 +++++++++++++++- scripts/utils.js | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 0099d379..067971eb 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,10 @@ {% assign greyscaleIconsUnsortedString = "" %} {% for icon in site.data.simple-icons.icons %} {% assign title = icon.title %} + {% assign filename = icon.title %} + + {% comment %} Replace a period by 'dot' {% endcomment %} {% assign _splitFilename = filename | split: "" %} {% if _splitFilename.first == "." %} {% assign filename = filename | replace_first: ".", "dot-" %} @@ -14,7 +17,18 @@ {% assign _filenameLenMin1 = filename | size | minus: 1 %} {% assign filename = filename | slice: 0, _filenameLenMin1 | append: "-dot" %} {% endif %} - {% assign filename = filename | replace: "+", "plus" | replace: " ", "" | replace: ".", "-dot-" | replace: "!", "" | replace: "’", "" | downcase %} + + {% comment %} Replace an ampersand by 'and' {% endcomment %} + {% if _splitFilename.first == "&" %} + {% assign filename = filename | replace_first: "&", "and-" %} + {% endif %} + {% if _splitFilename.last == "&" %} + {% assign _filenameLenMin1 = filename | size | minus: 1 %} + {% assign filename = filename | slice: 0, _filenameLenMin1 | append: "-and" %} + {% endif %} + + {% assign filename = filename | replace: "+", "plus" | replace: " ", "" | replace: ".", "-dot-" | replace: "&", "-and-" | replace: "!", "" | replace: "’", "" | downcase %} + {% assign hex = icon.hex %} {% assign hex = icon.hex %} {% assign hexCharacter1 = hex | slice: 0, 1 %} diff --git a/scripts/utils.js b/scripts/utils.js index 9cd21c9e..f8c6d775 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -9,6 +9,9 @@ module.exports = { .replace(/^\./, "dot-") .replace(/\.$/, "-dot") .replace(/\./g, "-dot-") + .replace(/^&/, "and-") + .replace(/&$/, "-and") + .replace(/&/g, "-and-") .replace(/[ !’]/g, "") ) }