@@ -1729,6 +1729,7 @@ public void markdownFencedCodeBlocks() {
17291729/// - ```
17301730/// code block
17311731/// in a list
1732+ /// with an indented line
17321733/// ```
17331734///
17341735/// - flibbertigibbet
@@ -1763,6 +1764,7 @@ class Test {}
17631764/// - ```
17641765/// code block
17651766/// in a list
1767+ /// with an indented line
17661768/// ```
17671769///
17681770/// - flibbertigibbet
@@ -2050,6 +2052,79 @@ private void doFormatTest(String input, String expected) {
20502052 }
20512053 }
20522054
2055+ @ Test
2056+ public void markdownBlankLinesAroundSnippetAndNoMangling () {
2057+ assume ().that (MARKDOWN_JAVADOC_SUPPORTED ).isTrue ();
2058+ String input =
2059+ """
2060+ /// hello world
2061+ /// {@snippet :
2062+ /// public class Foo {
2063+ /// private String s;
2064+ /// }
2065+ /// }
2066+ /// hello again
2067+ class Test {}\
2068+ """ ;
2069+ // TODO(b/530531076): Restore the indentation of `private String s;`
2070+ String expected =
2071+ """
2072+ /// hello world
2073+ ///
2074+ /// {@snippet :
2075+ /// public class Foo {
2076+ /// private String s;
2077+ /// }
2078+ /// }
2079+ ///
2080+ /// hello again
2081+ class Test {}
2082+ """ ;
2083+ doFormatTest (input , expected );
2084+ }
2085+
2086+ @ Test
2087+ public void markdownLongCommentOnEnumConstant () {
2088+ assume ().that (MARKDOWN_JAVADOC_SUPPORTED ).isTrue ();
2089+ String input =
2090+ """
2091+ enum Foo {
2092+ /// Long long long, longedy long, más fada an lá tig an oíche, chaise longue, caffè lungo, ich bin so lang nicht bei dir gewest
2093+ BAR,
2094+ }
2095+ """ ;
2096+ // TODO(b/530532338): The wrapped line should have /// not //
2097+ String expected =
2098+ """
2099+ enum Foo {
2100+ /// Long long long, longedy long, más fada an lá tig an oíche, chaise longue, caffè lungo, ich bin
2101+ // so lang nicht bei dir gewest
2102+ BAR,
2103+ }
2104+ """ ;
2105+ doFormatTest (input , expected );
2106+ }
2107+
2108+ @ Test
2109+ public void markdownLongCommentOnPackageDeclaration () {
2110+ assume ().that (MARKDOWN_JAVADOC_SUPPORTED ).isTrue ();
2111+ // A package doc comment is only really valid in package-info.java, but let's assume this is one
2112+ // of those.
2113+ String input =
2114+ """
2115+ /// Long long long, longedy long, más fada an lá tig an oíche, chaise longue, caffè lungo, ich bin so lang nicht bei dir gewest
2116+ package com.example;
2117+ """ ;
2118+ // TODO(b/530532338): The wrapped line should have /// not //
2119+ String expected =
2120+ """
2121+ /// Long long long, longedy long, más fada an lá tig an oíche, chaise longue, caffè lungo, ich bin
2122+ // so lang nicht bei dir gewest
2123+ package com.example;
2124+ """ ;
2125+ doFormatTest (input , expected );
2126+ }
2127+
20532128 // TODO: b/346668798 - Test the following Markdown constructs, and make the tests work as needed.
20542129 // We can assume that the CommonMark parser correctly handles Markdown, so the question is whether
20552130 // they are subsequently mishandled by our formatting logic. So for example the CommonMark parser
0 commit comments