Skip to content

Commit efeecc5

Browse files
eamonnmcmanusgoogle-java-format Team
authored andcommitted
In Markdown Javadoc, indent continuation lines for Javadoc block tags by +2 rather than +4.
The reason is that a +4 indentation could be interpreted as a Markdown [indented code block](https://spec.commonmark.org/0.31.2/#indented-code-blocks) in some circumstances. PiperOrigin-RevId: 954951163
1 parent bd4988b commit efeecc5

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

core/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocWriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ enum AutoIndent {
521521
private int innerIndent() {
522522
int innerIndent = continuingListItemStack.total() + continuingListStack.total();
523523
if (continuingFooterTag) {
524-
innerIndent += 4;
524+
innerIndent += classicJavadoc ? 4 : 2;
525525
}
526526
return innerIndent;
527527
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,17 +1980,15 @@ public void markdownBlockTagContinuationLines() {
19801980
/// rather than +4.
19811981
record Test(String foo) {}
19821982
""";
1983-
// TODO(b/537488642): continuation lines should be +2 to avoid the bug here.
1984-
// The four-space indentation leads to the second paragraph being interpreted as a code block.
19851983
String expected =
19861984
"""
19871985
/// Something something something.
19881986
///
19891987
/// @param foo a parameter with a long description that will need to be wrapped onto multiple lines,
1990-
/// with each line being indented by the default amount for continuation lines in a block tag.
1988+
/// with each line being indented by the default amount for continuation lines in a block tag.
19911989
///
1992-
/// There is even a second paragraph which illustrates why the indentation should be +2 rather
1993-
/// than +4.
1990+
/// There is even a second paragraph which illustrates why the indentation should be +2 rather
1991+
/// than +4.
19941992
record Test(String foo) {}
19951993
""";
19961994

0 commit comments

Comments
 (0)