Repository navigation
Prevent Markdown Javadoc tokens from emitting uncommented newlines. - #1544
Merged
Merged
Conversation
When formatting `///` Markdown Javadoc comments, tokens containing raw newlines (from `LIST_ITEM_START_PATTERN` matching `-\n`, multi-line or unclosed HTML tags like `</pre\n\n<p>`, `FOOTER_TAG_PATTERN` matching `@param\n<T>`, and multi-line MOE strip comments) were written verbatim, emitting bare uncommented lines that corrupted Java code or split comments. Restrict `LIST_ITEM_START_PATTERN` to horizontal whitespace (`[ \t]?`), bound `visitListItemOrBlockQuote` to `endPosition(node)`, and normalize internal whitespace in `FooterJavadocTagStart` and MOE strip comment tokens. Avoid consuming trailing horizontal whitespace together with `\n` outside formatting-preserving contexts in Markdown mode so `NEWLINE_PATTERN` does not skip close tokens at the end of a line (`MARKDOWN_HARD_LINE_BREAK_PATTERN` is left unchanged). In `JavadocWriter`, write continuation lines of any multi-line token with the comment prefix (reusing this path for `writeHtmlComment`), defer the space after Markdown list markers while suppressing pending newlines/blank lines for same-line content, set `atStartOfLine` in `writeBeginJavadoc` for Markdown comments, and request a newline while clearing `atStartOfLine` when closing Markdown lists and block quotes. PiperOrigin-RevId: 1030639801
copybara-service
Bot
force-pushed
the
test_1028886732
branch
from
November 26, 2026 13:59
905f4b9 to
c8cd285
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prevent Markdown Javadoc tokens from emitting uncommented newlines.
When formatting
///Markdown Javadoc comments, tokens containing raw newlines (fromLIST_ITEM_START_PATTERNmatching-\n, multi-line or unclosed HTML tags like</pre\n\n<p>,FOOTER_TAG_PATTERNmatching@param\n<T>, and multi-line MOE strip comments) were written verbatim, emitting bare uncommented lines that corrupted Java code or split comments.Restrict
LIST_ITEM_START_PATTERNto horizontal whitespace ([ \t]?), boundvisitListItemOrBlockQuotetoendPosition(node), and normalize internal whitespace inFooterJavadocTagStartand MOE strip comment tokens. Avoid consuming trailing horizontal whitespace together with\noutside formatting-preserving contexts in Markdown mode soNEWLINE_PATTERNdoes not skip close tokens at the end of a line (MARKDOWN_HARD_LINE_BREAK_PATTERNis left unchanged). InJavadocWriter, write continuation lines of any multi-line token with the comment prefix (reusing this path forwriteHtmlComment), defer the space after Markdown list markers while suppressing pending newlines/blank lines for same-line content, setatStartOfLineinwriteBeginJavadocfor Markdown comments, and request a newline while clearingatStartOfLinewhen closing Markdown lists and block quotes.