* Format arbitrary multiline text for safe rendering inside a markdown table cell. * - Preserves line breaks by converting to * - Escapes pipe characters (|) to avoid breaking table columns * - Trims leading/trailing whitespace on each line * - Collapses multiple consecutive blank lines
(text)
| 248 | * @returns {string} table-safe content |
| 249 | */ |
| 250 | function formatTableCell(text) { |
| 251 | if (text === null || text === undefined) return ""; |
| 252 | let s = String(text); |
| 253 | // Normalize line endings |
| 254 | s = s.replace(/\r\n/g, "\n"); |
| 255 | // Split lines, trim, drop empty groups while preserving intentional breaks |
| 256 | const lines = s |
| 257 | .split("\n") |
| 258 | .map((l) => l.trim()) |
| 259 | .filter((_, idx, arr) => { |
| 260 | // Keep single blank lines, drop consecutive blanks |
| 261 | if (arr[idx] !== "") return true; |
| 262 | return arr[idx - 1] !== ""; // allow one blank, remove duplicates |
| 263 | }); |
| 264 | s = lines.join("\n"); |
| 265 | // Escape table pipes |
| 266 | s = s.replace(/\|/g, "|"); |
| 267 | // Convert remaining newlines to <br /> for a single-cell rendering |
| 268 | s = s.replace(/\n/g, "<br />"); |
| 269 | return s.trim(); |
| 270 | } |
| 271 | |
| 272 | function makeBadges(link, type, linkIntent = "source") { |
| 273 | const aka = AKA_INSTALL_URLS[type] || AKA_INSTALL_URLS.instructions; |
no outgoing calls
no test coverage detected