diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java
index bc7ea5efc9fe..09774f141807 100644
--- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java
+++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java
@@ -422,14 +422,8 @@ public class JDParser {
result.add(Pair.create(s1, marks[i]));
}
else {
- if (s1.isEmpty() || s1.equals(SELF_CLOSED_P_TAG)) {
- if (sb.length() != 0) {
- result.add(new Pair<>(sb.toString(), false));
- sb.setLength(0);
- }
- result.add(Pair.create(s1, marks[i]));
- }
- else if (mySettings.JD_PRESERVE_LINE_FEEDS) {
+ if (s1.isEmpty() || s1.equals(SELF_CLOSED_P_TAG) || isKeepLineFeedsIn(s1)) {
+ endParagraph(result, sb);
result.add(Pair.create(s1, marks[i]));
}
else {
@@ -444,6 +438,24 @@ public class JDParser {
return result;
}
+ private boolean isKeepLineFeedsIn(@NotNull String line) {
+ return mySettings.JD_PRESERVE_LINE_FEEDS || startsWithTag(line);
+ }
+
+ private static boolean startsWithTag(@NotNull String line) {
+ if (line.trim().startsWith("<")) {
+ return line.matches("\\s*?\\w+>.*");
+ }
+ return false;
+ }
+
+ private static void endParagraph(@NotNull List
+ * There might be lists in descriptions like this one:
+ * A description containing HTML tags
+ *
+ *
+ * which should be left as is, without any tags merged.
+ *
+ * There might be lists in descriptions like + * this one: + *