Commit b7de448
Prevent leading blank lines in list items when formatting block tags.
* Update `writeTableOpen`, `writePreOpen`, `writeBlockquoteOpenOrClose`, `writeMarkdownTable`, and `writeMarkdownFencedCodeBlock` in `JavadocWriter` to uniformly call `requestBlankLineForBlockTag()` (`if (wroteAnythingSignificant && !atStartOfLine)`), ensuring that block elements opening immediately at the start of a list item (`<li>` or `- `) do not get preceded by an unnecessary blank line.
* Update `writeListOpen` and `writeListItemOpen` in `JavadocWriter` to check `if (wroteAnythingSignificant)` before requesting a newline or blank line, and set `atStartOfLine = true` in `writeBeginJavadoc` for `///` comments. This prevents `google-java-format` from prepending a leading blank line (`///\n`) when a list is the very first element in a Javadoc comment.
* Fix a `NullPointerException` in `MarkdownPositions.visitListItem` when a Markdown list item has a non-`Paragraph` first child (such as `- <table>...</table>`), safely falling through when `firstChild` is not an instance of `Paragraph`.
* Update unit tests in `JavadocFormattingTest` (`tableInHtmlListItem`, `tableInMarkdownListItem`, `tableInsideMarkdownListItemAfterText`, and `markdownLooseLists`) to verify correct formatting without unwanted blank lines or `NullPointerException` crashes.
PiperOrigin-RevId: 9457551371 parent 77bee2d commit b7de448
3 files changed
Lines changed: 49 additions & 41 deletions
File tree
- core/src
- main/java/com/google/googlejavaformat/java/javadoc
- test/java/com/google/googlejavaformat/java
Lines changed: 20 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
| |||
190 | 191 | | |
191 | 192 | | |
192 | 193 | | |
193 | | - | |
| 194 | + | |
194 | 195 | | |
195 | 196 | | |
196 | 197 | | |
| |||
200 | 201 | | |
201 | 202 | | |
202 | 203 | | |
203 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
204 | 207 | | |
205 | 208 | | |
206 | 209 | | |
| |||
219 | 222 | | |
220 | 223 | | |
221 | 224 | | |
222 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
223 | 228 | | |
224 | 229 | | |
225 | 230 | | |
| |||
260 | 265 | | |
261 | 266 | | |
262 | 267 | | |
263 | | - | |
264 | | - | |
265 | | - | |
| 268 | + | |
266 | 269 | | |
267 | 270 | | |
268 | 271 | | |
269 | 272 | | |
270 | 273 | | |
271 | 274 | | |
272 | 275 | | |
273 | | - | |
274 | | - | |
275 | | - | |
| 276 | + | |
276 | 277 | | |
277 | 278 | | |
278 | 279 | | |
| |||
292 | 293 | | |
293 | 294 | | |
294 | 295 | | |
295 | | - | |
296 | | - | |
297 | | - | |
| 296 | + | |
298 | 297 | | |
299 | 298 | | |
300 | 299 | | |
| |||
343 | 342 | | |
344 | 343 | | |
345 | 344 | | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
| 345 | + | |
| 346 | + | |
350 | 347 | | |
351 | 348 | | |
352 | 349 | | |
| |||
363 | 360 | | |
364 | 361 | | |
365 | 362 | | |
366 | | - | |
367 | | - | |
368 | | - | |
| 363 | + | |
369 | 364 | | |
370 | 365 | | |
371 | 366 | | |
| |||
385 | 380 | | |
386 | 381 | | |
387 | 382 | | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
388 | 389 | | |
389 | 390 | | |
390 | 391 | | |
| |||
Lines changed: 11 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
Lines changed: 18 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1940 | 1940 | | |
1941 | 1941 | | |
1942 | 1942 | | |
1943 | | - | |
1944 | | - | |
| 1943 | + | |
1945 | 1944 | | |
1946 | 1945 | | |
1947 | | - | |
1948 | 1946 | | |
1949 | 1947 | | |
1950 | 1948 | | |
| |||
2216 | 2214 | | |
2217 | 2215 | | |
2218 | 2216 | | |
2219 | | - | |
2220 | | - | |
| 2217 | + | |
| 2218 | + | |
2221 | 2219 | | |
2222 | 2220 | | |
2223 | 2221 | | |
2224 | | - | |
2225 | | - | |
2226 | | - | |
| 2222 | + | |
2227 | 2223 | | |
2228 | 2224 | | |
2229 | 2225 | | |
| |||
2233 | 2229 | | |
2234 | 2230 | | |
2235 | 2231 | | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
2236 | 2246 | | |
2237 | 2247 | | |
2238 | 2248 | | |
| |||
2244 | 2254 | | |
2245 | 2255 | | |
2246 | 2256 | | |
2247 | | - | |
2248 | | - | |
2249 | 2257 | | |
2250 | 2258 | | |
2251 | | - | |
2252 | 2259 | | |
2253 | 2260 | | |
2254 | 2261 | | |
| |||
0 commit comments