From befb6bb382a300d12a8a6e9184e6c5857d4bbb6d Mon Sep 17 00:00:00 2001 From: Louis Vignier Date: Wed, 5 Mar 2025 13:30:12 +0100 Subject: [PATCH] [codeInspection.ui] Normalize code blocks in inspection descriptions #IJPL-180212 Fixed GitOrigin-RevId: b802f331e674234700fe04c9f0e5b4c87ecf4cca --- .../codeInspection/ui/DescriptionEditorPane.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/DescriptionEditorPane.kt b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/DescriptionEditorPane.kt index bc0e99c91bd9..20416f0b7532 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/DescriptionEditorPane.kt +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/DescriptionEditorPane.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.profile.codeInspection.ui import com.intellij.lang.Language @@ -67,7 +67,13 @@ fun JEditorPane.readHTML(text: @Nls String) { */ fun JEditorPane.readHTMLWithCodeHighlighting(text: String, language: String?) { var lang = Language.findLanguageByID(language) ?: PlainTextLanguage.INSTANCE - val document = Jsoup.parse(text) + + // IJPL-180212 + @Suppress("HardCodedStringLiteral") + val normalizedText = Regex("\\s*") + .replace(text, "") + + val document = Jsoup.parse(normalizedText) // IDEA-318323 if (text.contains("\n

")) { @@ -84,7 +90,6 @@ fun JEditorPane.readHTMLWithCodeHighlighting(text: String, language: String?) { } try { - @Suppress("HardCodedStringLiteral") setText(document.html()) } catch (e: IOException) {