mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-05 23:12:39 +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) {
|
const getSourceText = function (brewText, type) {
|
||||||
if(type == 'source') {
|
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') {
|
} else if(type == 'download') {
|
||||||
return brewText;
|
return brewText;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user