mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed IDEA-143120 Javadoc HTML proper formatting
merged HTML lines with "wrapped at right margin" option
This commit is contained in:
@@ -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<Pair<String, Boolean>> result, @NotNull StringBuilder sb) {
|
||||
if (sb.length() > 0) {
|
||||
result.add(new Pair<>(sb.toString(), false));
|
||||
sb.setLength(0);
|
||||
}
|
||||
}
|
||||
|
||||
private interface TagParser {
|
||||
boolean parse(String tag, String line, JDComment c);
|
||||
}
|
||||
|
||||
@@ -1023,4 +1023,63 @@ module M {
|
||||
module M {
|
||||
}""")
|
||||
}
|
||||
|
||||
fun testRichHtml() {
|
||||
getSettings().WRAP_COMMENTS = true
|
||||
getSettings().RIGHT_MARGIN = 50
|
||||
getJavaSettings().JD_ADD_BLANK_AFTER_DESCRIPTION = false
|
||||
doTextTest(
|
||||
"""public class Test {
|
||||
/**
|
||||
* <h1>A description containing HTML tags</h1>
|
||||
* <p>
|
||||
* There might be lists in descriptions like this one:
|
||||
* <ul>
|
||||
* <li>Item one</li>
|
||||
* <li>Item two</li>
|
||||
* <li>Item three</li>
|
||||
* </ul>
|
||||
* which should be left as is, without any tags merged.
|
||||
* </p>
|
||||
* @param a Parameter descriptions can also be long but tag
|
||||
* content should be left intact:
|
||||
* <ol>
|
||||
* <li>Another item one</li>
|
||||
* <li>Item two</li>
|
||||
* </ol>
|
||||
*/
|
||||
void test(int a) {
|
||||
}
|
||||
}
|
||||
""",
|
||||
|
||||
"""public class Test {
|
||||
/**
|
||||
* <h1>A description containing HTML
|
||||
* tags</h1>
|
||||
* <p>
|
||||
* There might be lists in descriptions like
|
||||
* this one:
|
||||
* <ul>
|
||||
* <li>Item one</li>
|
||||
* <li>Item two</li>
|
||||
* <li>Item three</li>
|
||||
* </ul>
|
||||
* which should be left as is, without any
|
||||
* tags merged.
|
||||
* </p>
|
||||
* @param a Parameter descriptions can also be
|
||||
* long but tag content should be
|
||||
* left intact:
|
||||
* <ol>
|
||||
* <li>Another item one</li>
|
||||
* <li>Item two</li>
|
||||
* </ol>
|
||||
*/
|
||||
void test(int a) {
|
||||
}
|
||||
}
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user