0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Expand source text escaping/processing for improved readability

This commit is contained in:
Sean Robertson
2021-01-22 13:56:29 +13:00
parent 06223d576d
commit 21f08c97a1

View File

@@ -112,7 +112,12 @@ const setSourceHeaders = function (res, title, type) {
const getSourceText = function (brewText, type) {
if(type == 'source') {
return `<code><pre style="white-space: pre-wrap;">${brewText.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;')}</pre></code>`;
const replaceStrings = { '&': '&amp;', '<': '&lt;', '>': '&gt;' };
const text = brewText;
for (const replaceStr in replaceStrings) {
text = text.replaceAll(replaceStr, replaceStrings[replaceStr]);
}
return `<code><pre style="white-space: pre-wrap;">${text}</pre></code>`;
} else if(type == 'download') {
return brewText;
} else {