Skip to content

Commit 87197ec

Browse files
eamonnmcmanusgoogle-java-format Team
authored andcommitted
Add a test case to ensure that line wrapping doesn't split Markdown links.
It would be wrong to introduce space, including a line break, between the `]` and the `(` of `[foo](bar)`. PiperOrigin-RevId: 908143630
1 parent 70eb845 commit 87197ec

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,6 +1831,25 @@ class Test {}
18311831
doFormatTest(input, expected);
18321832
}
18331833

1834+
@Test
1835+
public void markdownLinkWrapping() {
1836+
assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();
1837+
String input =
1838+
"""
1839+
/// enough text to cause the following link to need to be wrapped [foo](http://very.long/url/that/will/need/to/be/wrapped)
1840+
class Test {}
1841+
""";
1842+
// It would be wrong to wrap between the ] and the (, and fortunately we don't.
1843+
// https://spec.commonmark.org/0.31.2/#example-511
1844+
String expected =
1845+
"""
1846+
/// enough text to cause the following link to need to be wrapped
1847+
/// [foo](http://very.long/url/that/will/need/to/be/wrapped)
1848+
class Test {}
1849+
""";
1850+
doFormatTest(input, expected);
1851+
}
1852+
18341853
@Test
18351854
public void markdownThematicBreaks() {
18361855
assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();

0 commit comments

Comments
 (0)