Skip to content

fix(html): backtrack jsdoc summary ending with ':' to last '.'#799

Open
nanookclaw wants to merge 1 commit into
denoland:mainfrom
nanookclaw:fix/jsdoc-summary-trailing-colon
Open

fix(html): backtrack jsdoc summary ending with ':' to last '.'#799
nanookclaw wants to merge 1 commit into
denoland:mainfrom
nanookclaw:fix/jsdoc-summary-trailing-colon

Conversation

@nanookclaw
Copy link
Copy Markdown

@nanookclaw nanookclaw commented May 19, 2026

Closes #633.

When rendering a title-only JSDoc summary, if the trimmed plain text ends with :, walk back to the last . and shorten the rendered output to end there. If there's no ., leave the summary as-is. The fix only touches the title_only branch in create_renderer; full-markdown rendering is unchanged.

Implementation

Three private helpers added to src/html/comrak.rs:

  • collect_inline_plain_text — concatenates the inline subtree's plain text (Text + Code literals; SoftBreak → space). After walk_node_title the first paragraph holds only inline nodes, so this is well-defined.
  • shorten_inline_to — walks the inline tree in document order with a byte offset; shortens the literal that straddles the target and detaches later siblings.
  • shorten_title_summary_trailing_colon — the policy: only act when trimmed plain text ends with : and contains a ., then target last_dot + 1. No-op otherwise.

Called between walk_node_title(root) and render_node(root.first_child(), ...).

Tests

Six unit tests in src/html/comrak.rs:

  • trailing : with prior . shortens to last .
  • trailing : with no . left unchanged
  • no trailing : left unchanged
  • trailing : after a code span backtracks past it
  • trailing : after emphasis backtracks past it
  • last . lives inside a code span — code span is kept up to and including ., trailing text/colon dropped

All pass via cargo test --lib html::comrak::. cargo check, cargo fmt -- --check, and deno task tailwind clean.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 19, 2026

CLA assistant check
All committers have signed the CLA.

@nanookclaw
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@nanookclaw nanookclaw force-pushed the fix/jsdoc-summary-trailing-colon branch from b0e8bdc to ce7efb1 Compare May 19, 2026 19:29
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.

jsdoc rendering summary can end with a :

2 participants