(paragraph)
| 149 | } |
| 150 | |
| 151 | function firstSentence(paragraph) { |
| 152 | const collapsed = paragraph.replace(/\s+/gu, " ").trim(); |
| 153 | |
| 154 | if (collapsed === "") { |
| 155 | return ""; |
| 156 | } |
| 157 | |
| 158 | const sentence = /^(.*?[.!?])(?:\s|$)/u.exec(collapsed)?.[1]; |
| 159 | |
| 160 | if (sentence !== undefined) { |
| 161 | return sentence; |
| 162 | } |
| 163 | |
| 164 | // No sentence terminator: this is a colon/semicolon lead-in (e.g. |
| 165 | // "Scaffolds a new API resource:") whose detail lives in an indented list |
| 166 | // we deliberately dropped. Normalize the dangling mark to a period so the |
| 167 | // catalog reads as a complete summary instead of a fragment. |
| 168 | return collapsed.replace(/[:;,]+$/u, "."); |
| 169 | } |
| 170 | |
| 171 | // Assemble the first prose paragraph, then keep its first sentence. Lines that |
| 172 | // the header indents (usage examples, bullet lists) end the paragraph — pulling |
no outgoing calls
no test coverage detected