mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: render tags inside javadoc blockquote+pre correctly (IDEA-353552)
GitOrigin-RevId: 75dfee7012de46aff860b16acdc98588e5e6eaea
This commit is contained in:
committed by
intellij-monorepo-bot
parent
bd3ed55093
commit
51407fc59f
@@ -1904,14 +1904,20 @@ public class JavaDocInfoGenerator {
|
||||
int suffixIndex = text.indexOf(suffix);
|
||||
if (suffixIndex >= 0) {
|
||||
htmlCodeBlockContents.append(text, 0, suffixIndex);
|
||||
buffer.append(CODE_BLOCK_PREFIX);
|
||||
appendHighlightedByLexerAndEncodedAsHtmlCodeSnippet(
|
||||
doHighlightCodeBlocks(), buffer, myProject, JavaLanguage.INSTANCE,
|
||||
StringUtil.unescapeXmlEntities(StringUtil.replaceUnicodeEscapeSequences(htmlCodeBlockContents.toString()))
|
||||
.replace(" ", " ")
|
||||
.replace("@", "@")
|
||||
);
|
||||
buffer.append(CODE_BLOCK_SUFFIX);
|
||||
buffer.append(prefix);
|
||||
String contentString = htmlCodeBlockContents.toString();
|
||||
if (contentString.indexOf('<') >= 0 && BLOCKQUOTE_PRE_PREFIX.equals(prefix)) {
|
||||
appendPlainText(buffer, contentString);
|
||||
}
|
||||
else {
|
||||
appendHighlightedByLexerAndEncodedAsHtmlCodeSnippet(
|
||||
doHighlightCodeBlocks(), buffer, myProject, JavaLanguage.INSTANCE,
|
||||
StringUtil.unescapeXmlEntities(StringUtil.replaceUnicodeEscapeSequences(contentString))
|
||||
.replace(" ", " ")
|
||||
.replace("@", "@")
|
||||
);
|
||||
}
|
||||
buffer.append(suffix);
|
||||
appendPlainText(buffer, text.substring(suffixIndex + suffix.length()));
|
||||
return null;
|
||||
}
|
||||
|
||||
+3
-3
@@ -7,11 +7,11 @@
|
||||
Strings are constant; their values cannot be changed after they
|
||||
are created. String buffers support mutable strings.
|
||||
Because String objects are immutable they can be shared. For example:
|
||||
<p><pre><code><span style="">String str = </span><span style="color:#008000;font-weight:bold;">"abc"</span><span style="">;</span></code></pre><p>
|
||||
<p><blockquote><pre><span style="">String str = </span><span style="color:#008000;font-weight:bold;">"abc"</span><span style="">;</span></pre></blockquote><p>
|
||||
is equivalent to:
|
||||
<p><pre><code><span style="color:#000080;font-weight:bold;">char </span><span style="">data[] = {</span><span style="color:#008000;font-weight:bold;">'a'</span><span style="">, </span><span style="color:#008000;font-weight:bold;">'b'</span><span style="">, </span><span style="color:#008000;font-weight:bold;">'c'</span><span style="">};<br></span><span style="">String str = </span><span style="color:#000080;font-weight:bold;">new </span><span style="">String(data);</span></code></pre><p>
|
||||
<p><blockquote><pre><span style="color:#000080;font-weight:bold;">char </span><span style="">data[] = {</span><span style="color:#008000;font-weight:bold;">'a'</span><span style="">, </span><span style="color:#008000;font-weight:bold;">'b'</span><span style="">, </span><span style="color:#008000;font-weight:bold;">'c'</span><span style="">};<br></span><span style="">String str = </span><span style="color:#000080;font-weight:bold;">new </span><span style="">String(data);</span></pre></blockquote><p>
|
||||
Here are some more examples of how strings can be used:
|
||||
<p><pre><code><span style="">System.out.println(</span><span style="color:#008000;font-weight:bold;">"abc"</span><span style="">);<br></span><span style="">String cde = </span><span style="color:#008000;font-weight:bold;">"cde"</span><span style="">;<br></span><span style="">System.out.println(</span><span style="color:#008000;font-weight:bold;">"abc" </span><span style="">+ cde);<br></span><span style="">String c = </span><span style="color:#008000;font-weight:bold;">"abc"</span><span style="">.substring(</span><span style="color:#0000ff;">2</span><span style="">,</span><span style="color:#0000ff;">3</span><span style="">);<br></span><span style="">String d = cde.substring(</span><span style="color:#0000ff;">1</span><span style="">, </span><span style="color:#0000ff;">2</span><span style="">);</span></code></pre>
|
||||
<p><blockquote><pre><span style="">System.out.println(</span><span style="color:#008000;font-weight:bold;">"abc"</span><span style="">);<br></span><span style="">String cde = </span><span style="color:#008000;font-weight:bold;">"cde"</span><span style="">;<br></span><span style="">System.out.println(</span><span style="color:#008000;font-weight:bold;">"abc" </span><span style="">+ cde);<br></span><span style="">String c = </span><span style="color:#008000;font-weight:bold;">"abc"</span><span style="">.substring(</span><span style="color:#0000ff;">2</span><span style="">,</span><span style="color:#0000ff;">3</span><span style="">);<br></span><span style="">String d = cde.substring(</span><span style="color:#0000ff;">1</span><span style="">, </span><span style="color:#0000ff;">2</span><span style="">);</span></pre></blockquote>
|
||||
<p>
|
||||
The class <code>String</code> includes methods for examining
|
||||
individual characters of the sequence, for comparing strings, for
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 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.java.codeInsight
|
||||
|
||||
import com.intellij.codeInsight.documentation.DocumentationManager
|
||||
@@ -363,12 +363,14 @@ class JavaDocumentationTest : LightJavaCodeInsightFixtureTestCase() {
|
||||
val expected = """
|
||||
<div class="bottom"><icon src="AllIcons.Nodes.Class"> <a href="psi_element://C"><code><span style="color:#000000;">C</span></code></a></div><div class='definition'><pre><span style="color:#000080;font-weight:bold;">public</span> <span style="color:#000080;font-weight:bold;">void</span> <span style="color:#000000;">m</span><span style="">(</span><span style="">)</span></pre></div><div class='content'>
|
||||
<p> Examples of expected usage:
|
||||
<pre><code><span style="">StringBuilder sb = </span><span style="color:#000080;font-weight:bold;">new </span><span style="">StringBuilder();</span></code></pre>
|
||||
<blockquote><pre><span style="">StringBuilder sb = </span><span style="color:#000080;font-weight:bold;">new </span><span style="">StringBuilder();</span></pre></blockquote>
|
||||
<pre><code><span style="">StringBuilder sb = </span><span style="color:#000080;font-weight:bold;">new </span><span style="">StringBuilder();</span></code></pre>
|
||||
<p> Continuing...
|
||||
<pre><code><span style="">quote nr </span><span style="color:#0000ff;">2</span><span style="">;</span></code></pre>
|
||||
<blockquote><pre><span style="">quote nr </span><span style="color:#0000ff;">2</span><span style="">;</span></pre></blockquote>
|
||||
<p> Continuing...
|
||||
<pre><code><span style="">(</span><span style="color:#000080;font-weight:bold;">this</span><span style="">.charAt(<i>k</i>) == ch) && (<i>k</i> <= fromIndex)</span></code></pre>
|
||||
<blockquote><pre>
|
||||
(this.charAt(<i>k</i>) == ch) && (<i>k</i> <= fromIndex)
|
||||
</pre></blockquote>
|
||||
<blockquote><pre>
|
||||
Unfinished blockquote
|
||||
</pre> </blockquote>
|
||||
|
||||
Reference in New Issue
Block a user