diff --git a/src/public/app/widgets/type_widgets/read_only_code.ts b/src/public/app/widgets/type_widgets/read_only_code.ts index 4d7ce3ab0..24715c96b 100644 --- a/src/public/app/widgets/type_widgets/read_only_code.ts +++ b/src/public/app/widgets/type_widgets/read_only_code.ts @@ -67,9 +67,10 @@ export default class ReadOnlyCodeTypeWidget extends AbstractCodeTypeWidget { let pre: { indent: string; tag: string }[] = []; html = html - .replace(new RegExp("
((.|\\t|\\n|\\r)+)?"), function (x) { - pre.push({ indent: "", tag: x }); - return "<--TEMPPRE" + i++ + "/-->"; + // match everything, including whitespace/newline characters + .replace(/
((.)+)?<\/pre>/s, (match) => { + pre.push({ indent: "", tag: match }); + return `<--TEMPPRE${i++}/-->`; }) .replace(new RegExp("<[^<>]+>[^<]?", "g"), function (x) { let ret;