(text, currentRel)
| 328 | } |
| 329 | |
| 330 | function inline(text, currentRel) { |
| 331 | const stash = []; |
| 332 | let out = text.replace(/`([^`]+)`/g, (_, code) => { |
| 333 | stash.push(`<code>${escapeHtml(code)}</code>`); |
| 334 | return `@@CODE${stash.length - 1}@@`; |
| 335 | }); |
| 336 | out = escapeHtml(out) |
| 337 | .replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>") |
| 338 | .replace( |
| 339 | /\[([^\]]+)\]\(([^)]+)\)/g, |
| 340 | (_, label, href) => `<a href="${escapeAttr(rewriteHref(href, currentRel))}">${label}</a>`, |
| 341 | ); |
| 342 | return out.replace(/@@CODE(\d+)@@/g, (_, i) => stash[Number(i)]); |
| 343 | } |
| 344 | |
| 345 | function rewriteHref(href, currentRel) { |
| 346 | if (/^(https?:|mailto:|#)/.test(href)) return href; |
no test coverage detected