Skip to content

Commit b97f4a8

Browse files
eamonnmcmanusgoogle-java-format Team
authored andcommitted
Add tables to the to-do list for Markdown Javadoc, plus a test illustrating the current mangling.
PiperOrigin-RevId: 904634808
1 parent ebe9da7 commit b97f4a8

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,6 +1988,30 @@ class Test {}
19881988
doFormatTest(input, expected);
19891989
}
19901990

1991+
@Test
1992+
public void markdownTables() {
1993+
assume().that(MARKDOWN_JAVADOC_SUPPORTED).isTrue();
1994+
String input =
1995+
"""
1996+
/// | foo | bar |
1997+
/// | --- | --- |
1998+
/// | baz | qux |
1999+
///
2000+
/// - |foo|bar|
2001+
/// |--:|:--|
2002+
/// |baz|qux|
2003+
class Test {}
2004+
""";
2005+
// TODO: unmangle the tables
2006+
String expected =
2007+
"""
2008+
/// | foo | bar | | --- | --- | | baz | qux |
2009+
/// - |foo|bar| |--:|:--| |baz|qux|
2010+
class Test {}
2011+
""";
2012+
doFormatTest(input, expected);
2013+
}
2014+
19912015
// TODO: b/346668798 - Test the following Markdown constructs, and make the tests work as needed.
19922016
// We can assume that the CommonMark parser correctly handles Markdown, so the question is whether
19932017
// they are subsequently mishandled by our formatting logic. So for example the CommonMark parser
@@ -2027,4 +2051,10 @@ class Test {}
20272051
//
20282052
// - Autolinks
20292053
// <http://example.com> should be preserved. https://spec.commonmark.org/0.31.2/#autolink
2054+
//
2055+
// - Tables
2056+
// | foo | bar |
2057+
// | --- | --- |
2058+
// | baz | qux |
2059+
// Probably we should just try not to mangle them. https://spec.commonmark.org/0.31.2/#tables
20302060
}

0 commit comments

Comments
 (0)