Commit 0e485a8
Prevent leading blank lines in list items when formatting block tags.
* Update `writeTableOpen`, `writePreOpen`, and `writeBlockquoteOpenOrClose` in `JavadocWriter` to check `if (wroteAnythingSignificant && !atStartOfLine)` before requesting a blank line. This matches existing logic in `writeMarkdownTable` (`line 378`) and `writeMarkdownFencedCodeBlock` (`line 346`), ensuring that block elements opening immediately at the start of a list item (`<li>` or `- `) do not get preceded by an unnecessary blank line.
* 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` and `tableInMarkdownListItem`) to verify correct formatting and verify no `NullPointerException` is thrown when `- <table>` is lexed.
PiperOrigin-RevId: 9457551371 parent 77bee2d commit 0e485a8
3 files changed
Lines changed: 35 additions & 21 deletions
File tree
- core/src
- main/java/com/google/googlejavaformat/java/javadoc
- test/java/com/google/googlejavaformat/java
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
264 | 264 | | |
265 | 265 | | |
266 | 266 | | |
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
295 | | - | |
| 295 | + | |
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
| |||
Lines changed: 10 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 | + | |
143 | 142 | | |
144 | 143 | | |
145 | 144 | | |
| |||
Lines changed: 22 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2216 | 2216 | | |
2217 | 2217 | | |
2218 | 2218 | | |
2219 | | - | |
2220 | | - | |
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 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
2236 | 2253 | | |
2237 | 2254 | | |
2238 | 2255 | | |
| |||
2244 | 2261 | | |
2245 | 2262 | | |
2246 | 2263 | | |
2247 | | - | |
2248 | | - | |
2249 | 2264 | | |
2250 | 2265 | | |
2251 | 2266 | | |
| |||
0 commit comments