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 f9a399b53..72f1d784f 100644
--- a/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java
+++ b/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java
@@ -1775,6 +1775,187 @@ class Test {}
doFormatTest(input, expected);
}
+ @Test
+ public void markdownBackslashes() {
+ assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();
+ String input =
+ """
+ /// \\
is not a break.
+ /// \\* is not an HTML entity.
+ /// foo\\
+ /// bar
+ class Test {}
+ """;
+ // TODO: the
should not cause a line break, and the end-of-line backslash should.
+ // I don't think anything changes if we do or do not respect the \& backslash.
+ String expected =
+ """
+ /// \\
+ /// is not a break. \\* is not an HTML entity. foo\\ bar
+ class Test {}
+ """;
+ doFormatTest(input, expected);
+ }
+
+ @Test
+ public void markdownThematicBreaks() {
+ assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();
+ String input =
+ """
+ /// foo
+ /// ***
+ /// bar
+ class Test {}
+ """;
+ // TODO: the line break before `***` should be preserved.
+ // It's OK to introduce a blank line before `bar` since it is a new paragraph.
+ String expected =
+ """
+ /// foo ***
+ ///
+ /// bar
+ class Test {}
+ """;
+ doFormatTest(input, expected);
+ }
+
+ @Test
+ public void markdownSetextHeadings() {
+ assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();
+ String input =
+ """
+ /// Heading
+ /// =======
+ /// Phoebe B. Peabody-Beebe
+ ///
+ /// Subheading
+ /// ----------
+ class Test {}
+ """;
+ // TODO: the line breaks before the lines of repeated characters should be preserved.
+ // Or, we could rewrite this style of heading as `# Heading`.
+ String expected =
+ """
+ /// Heading =======
+ ///
+ /// Phoebe B. Peabody-Beebe
+ ///
+ /// Subheading ----------
+ class Test {}
+ """;
+ doFormatTest(input, expected);
+ }
+
+ @Test
+ public void markdownIndentedCodeBlocks() {
+ assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();
+ String input =
+ """
+ /// code block
+ /// is indented
+ class Test {}
+ """;
+ // TODO: the evil indented code block should be preserved.
+ String expected =
+ """
+ /// code block is indented
+ class Test {}
+ """;
+ doFormatTest(input, expected);
+ }
+
+ @Test
+ public void markdownLinkReferenceDefinitions() {
+ assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();
+ String input =
+ """
+ /// [foo]
+ /// [foo]: /url "title"
+ class Test {}
+ """;
+ String expected =
+ """
+ /// [foo] [foo]: /url "title"
+ class Test {}
+ """;
+ doFormatTest(input, expected);
+ }
+
+ @Test
+ public void markdownLooseLists() {
+ assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();
+ String input =
+ """
+ /// - item 1
+ ///
+ /// - item 2
+ class Test {}
+ """;
+ // TODO: the line break between items should be preserved, and there should not be a blank line
+ // before the list.
+ String expected =
+ """
+ ///
+ /// - item 1
+ /// - item 2
+ class Test {}
+ """;
+ doFormatTest(input, expected);
+ }
+
+ @Test
+ public void markdownBlockQuotes() {
+ assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();
+ String input =
+ """
+ /// > foo
+ /// > bar
+ class Test {}
+ """;
+ // TODO: the block quote should be preserved, and ideally bar would be joined to foo.
+ String expected =
+ """
+ /// >
+ ///
+ /// foo > bar
+ class Test {}
+ """;
+ doFormatTest(input, expected);
+ }
+
+ @Test
+ public void markdownCodeSpans() {
+ assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();
+ String input =
+ """
+ /// `