diff --git a/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java b/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java
index b965344cf..6a5214d2a 100644
--- a/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java
+++ b/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java
@@ -2652,6 +2652,245 @@ class Test {}
doFormatTest(input, expected);
}
+ @Test
+ public void markdownHtmlListItemFollowedByParagraph() {
+ assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();
+ String input =
+ """
+ class T {
+ /// Updates:
+ ///
A single [Foo]
+ /// One or more [Bar]s
+ ///
+ /// See [Baz] for more details.
+ void m() {}
+
+ /// Updates:
+ ///
First item
+ /// Following paragraph without blank line.
+ void n() {}
+ }
+ """;
+ // Baseline: HTML `
` pushes 4-space indent, turning `` into an indented code block.
+ String expected =
+ """
+ class T {
+ /// Updates:
+ ///
A single [Foo]
+ /// One or more [Bar]s
+ ///
+ /// See [Baz] for more details.
+ void m() {}
+
+ /// Updates:
+ ///
First item
+ ///
+ /// Following paragraph without blank line.
+ void n() {}
+ }
+ """;
+ doFormatTest(input, expected);
+ }
+
+ @Test
+ public void markdownHtmlUnorderedAndDefinitionLists() {
+ assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();
+ String input =
+ """
+ class T {
+ /// Intro:
+ ///
+ /// - First item
+ ///
+ ///
Second paragraph.
+ ///
- Second item
+ ///
+ /// Following text.
+ ///
+ ///
+ /// text without li
+ ///
+ ///
+ ///
+ /// - Term
+ ///
- Definition
+ ///
+ ///
More details.
+ ///
+ void m() {}
+ }
+ """;
+ // Baseline: HTML list tags push 2+4+ spaces of indentation (turning paragraphs into indented
+ // code blocks) and join `` onto adjacent lines.
+ String expected =
+ """
+ class T {
+ /// Intro:
+ /// - First item
+ ///
+ ///
Second paragraph.
+ ///
- Second item
Following text.
+ ///
+ ///
+ ///
+ ///
+ /// - Term
+ ///
- Definition
+ ///
+ ///
More details.
+ void m() {}
+ }
+ """;
+ doFormatTest(input, expected);
+ }
+
+ @Test
+ public void markdownNestedHtmlLists() {
+ assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();
+ String input =
+ """
+ class T {
+ /// Types:
+ ///
+ ///
+ /// - First
+ ///
Details for first.
+ ///
- Second
+ ///
Details for second.
+ ///
+ void m() {}
+
+ /// Works only if:
+ ///
+ ///
+ ///
+ /// Features:
+ ///
+ ///
+ void n() {}
+ }
+ """;
+ // Baseline: nested HTML lists push deep indentation, turning paragraphs into indented code
+ // blocks.
+ String expected =
+ """
+ class T {
+ /// Types:
+ ///
+ /// - First
+ ///
+ ///
Details for first.
+ ///
- Second
+ ///
+ ///
Details for second.
+ void m() {}
+
+ /// Works only if:
+ ///
+ /// First condition
+ /// Second condition
+ ///
+ /// Features:
+ ///
+ /// See [Foo].
+ void n() {}
+ }
+ """;
+ doFormatTest(input, expected);
+ }
+
+ @Test
+ public void markdownHtmlListInFooterTag() {
+ assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();
+ String input =
+ """
+ class T {
+ /// Summary.
+ ///
+ /// @param x values:
+ ///
+ /// - one
+ ///
more
+ ///
+ void m(int x) {}
+ }
+ """;
+ // Baseline: `@param` + `` + `- ` pushes 8-space indentation.
+ String expected =
+ """
+ class T {
+ /// Summary.
+ ///
+ /// @param x values:
+ /// - one
+ ///
+ ///
more
+ void m(int x) {}
+ }
+ """;
+ doFormatTest(input, expected);
+ }
+
+ @Test
+ public void markdownHtmlListInsideMarkdownContainers() {
+ assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();
+ String input =
+ """
+ class T {
+ /// - Outer item:
+ ///
+ /// - Bare HTML li
+ ///
+ ///
+ /// Following paragraph in outer item.
+ ///
+ /// >
+ /// > - Quoted HTML item
+ /// >
+ /// >
Quoted paragraph
+ /// >
+ void m() {}
+
+ /// - Bare HTML li
+ ///
+ /// - Markdown item 1
+ /// - Markdown item 2
+ void n() {}
+ }
+ """;
+ // Baseline: HTML list tags interfere with Markdown list indentation and turn following blocks
+ // into indented code blocks.
+ String expected =
+ """
+ class T {
+ /// - Outer item:
+ ///
- Bare HTML li
+ ///
+ /// Following paragraph in outer item.
+ ///
+ /// >
+ /// > - Quoted HTML item
+ /// >
+ /// >
Quoted paragraph
+ void m() {}
+
+ /// - Bare HTML li
+ ///
+ /// - Markdown item 1
+ /// - Markdown item 2
+ void n() {}
+ }
+ """;
+ doFormatTest(input, expected);
+ }
+
@Test
public void tableInsideMarkdownListItemAfterText() {
assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();