dprint-plugin-typescript icon indicating copy to clipboard operation
dprint-plugin-typescript copied to clipboard

fix: preserve jsdoc markdown hard breaks

Open jmolz opened this issue 5 months ago • 0 comments

Refs denoland/deno#31831.

JSDoc is commonly rendered as Markdown, but the TypeScript formatter currently trims two trailing spaces from non-final JSDoc lines. That removes Markdown hard line breaks. The Markdown plugin normalizes the same input to a backslash hard break, so this applies the same normalization to JSDoc lines while keeping non-JSDoc block comments on the existing trimming behavior.

The regression coverage also guards the main edge cases from the narrower behavior:

  • converts a JSDoc Markdown hard break when another content line follows
  • does not convert a hard break on the last meaningful JSDoc content line
  • does not convert trailing spaces inside a fenced JSDoc code block
  • does not convert hard breaks in non-JSDoc block comments

Tests:

  • cargo test --test specs issue031831
  • cargo test --test specs JSDocComments_All
  • cargo test --test specs CommentBlocks_All
  • cargo test

jmolz avatar Jun 06 '26 23:06 jmolz