Skip to content

Prevent leading blank lines in list items when formatting block tags.#1410

Closed
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_945755137
Closed

Prevent leading blank lines in list items when formatting block tags.#1410
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_945755137

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Jul 10, 2026

Copy link
Copy Markdown

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.

* 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: 945755137
@copybara-service copybara-service Bot closed this Jul 10, 2026
@copybara-service copybara-service Bot deleted the test_945755137 branch July 10, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant