refactor(read_only_code): split up the last TEMPPRE repalcement step

make it a bit more easy to read
This commit is contained in:
Panagiotis Papadopoulos 2025-03-01 10:05:13 +01:00
parent f5cb845659
commit 622945ab18

View File

@ -105,7 +105,11 @@ export default class ReadOnlyCodeTypeWidget extends AbstractCodeTypeWidget {
}); });
for (i = pre.length; i--; ) { for (i = pre.length; i--; ) {
html = html.replace("<--TEMPPRE" + i + "/-->", pre[i].tag.replace("<pre>", "<pre>\n").replace("</pre>", pre[i].indent + "</pre>")); const formattedPreTag = pre[i].tag
.replace("<pre>", "<pre>\n")
.replace("</pre>", pre[i].indent + "</pre>");
html = html.replace(`<--TEMPPRE${i}/-->`, formattedPreTag);
} }
return html.charAt(0) === "\n" ? html.substr(1, html.length - 1) : html; return html.charAt(0) === "\n" ? html.substr(1, html.length - 1) : html;