Skip to content

Commit 5498e81

Browse files
cpovirkgoogle-java-format Team
authored andcommitted
Remove interior blank lines inside blockquote.
Thanks to kak@ in 77bee2d for adding these tests! PiperOrigin-RevId: 945803637
1 parent 77bee2d commit 5498e81

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ private static String render(List<Token> input, int blockIndent, boolean classic
119119
case HeaderOpenTag t -> output.writeHeaderOpen(t);
120120
case HeaderCloseTag t -> output.writeHeaderClose(t);
121121
case ParagraphOpenTag t -> output.writeParagraphOpen(standardizePToken(t));
122-
case BlockquoteOpenTag t -> output.writeBlockquoteOpenOrClose(t);
123-
case BlockquoteCloseTag t -> output.writeBlockquoteOpenOrClose(t);
122+
case BlockquoteOpenTag t -> output.writeBlockquoteOpen(t);
123+
case BlockquoteCloseTag t -> output.writeBlockquoteClose(t);
124124
case PreOpenTag t -> output.writePreOpen(t);
125125
case PreCloseTag t -> output.writePreClose(t);
126126
case CodeOpenTag t -> output.writeCodeOpen(t);

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import static com.google.googlejavaformat.java.javadoc.JavadocWriter.RequestedWhitespace.NONE;
2424
import static com.google.googlejavaformat.java.javadoc.JavadocWriter.RequestedWhitespace.WHITESPACE;
2525

26+
import com.google.googlejavaformat.java.javadoc.Token.BlockquoteCloseTag;
27+
import com.google.googlejavaformat.java.javadoc.Token.BlockquoteOpenTag;
2628
import com.google.googlejavaformat.java.javadoc.Token.BrTag;
2729
import com.google.googlejavaformat.java.javadoc.Token.CodeCloseTag;
2830
import com.google.googlejavaformat.java.javadoc.Token.CodeOpenTag;
@@ -259,13 +261,23 @@ void writeParagraphOpen(Token token) {
259261
writeToken(token);
260262
}
261263

262-
void writeBlockquoteOpenOrClose(Token token) {
264+
void writeBlockquoteOpen(BlockquoteOpenTag token) {
263265
if (wroteAnythingSignificant) {
264266
requestBlankLine();
265267
}
266268

267269
writeToken(token);
268270

271+
requestNewline();
272+
}
273+
274+
void writeBlockquoteClose(BlockquoteCloseTag token) {
275+
if (wroteAnythingSignificant) {
276+
requestNewline();
277+
}
278+
279+
writeToken(token);
280+
269281
requestBlankLine();
270282
}
271283

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,6 @@ class Test {}\
716716
* <blockquote>
717717
*
718718
* <p>def
719-
*
720719
* </blockquote>
721720
*
722721
* ghi
@@ -2178,9 +2177,7 @@ class Test {}
21782177
String expected =
21792178
"""
21802179
/// <blockquote>
2181-
///
21822180
/// line 1 line 2
2183-
///
21842181
/// </blockquote>
21852182
class Test {}
21862183
""";

0 commit comments

Comments
 (0)