MCPcopy Index your code
hub / github.com/simstudioai/sim / plainTextToHtml

Function plainTextToHtml

apps/sim/tools/gmail/utils.ts:338–346  ·  view source on GitHub ↗
(body: string)

Source from the content-addressed store, hash-verified

336 * This avoids the narrow hard-wrapped rendering Gmail uses for `text/plain`.
337 */
338export function plainTextToHtml(body: string): string {
339 const normalized = body.replace(/\r\n/g, '\n').replace(/\r/g, '\n')
340 const paragraphs = normalized.split(/\n{2,}/)
341 const htmlParagraphs = paragraphs.map((paragraph) => {
342 const escaped = escapeHtml(paragraph).replace(/\n/g, '<br>')
343 return `<p>${escaped}</p>`
344 })
345 return `<!DOCTYPE html><html><body>${htmlParagraphs.join('')}</body></html>`
346}
347
348/**
349 * Best-effort conversion of an HTML body to a plain-text fallback. Used so we

Callers 2

utils.test.tsFile · 0.90
buildBodyAlternativesFunction · 0.85

Calls 3

joinMethod · 0.80
escapeHtmlFunction · 0.70
replaceMethod · 0.65

Tested by

no test coverage detected