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:
@@ -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('&', '&').replaceAll('<', '<').replaceAll('>', '>')}</pre></code>`;
|
||||
const replaceStrings = { '&': '&', '<': '<', '>': '>' };
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user