MCPcopy Index your code
hub / github.com/codeaashu/claude-code / toHTML

Function toHTML

web/lib/export/html.ts:117–154  ·  view source on GitHub ↗
(conv: Conversation, options: ExportOptions)

Source from the content-addressed store, hash-verified

115`;
116
117export function toHTML(conv: Conversation, options: ExportOptions): string {
118 let messages = conv.messages;
119 if (options.dateRange) {
120 const { start, end } = options.dateRange;
121 messages = messages.filter((m) => m.createdAt >= start && m.createdAt <= end);
122 }
123
124 const metaParts = [
125 ...(conv.model ? [`<span>Model: ${escapeHtml(conv.model)}</span>`] : []),
126 `<span>${messages.length} messages</span>`,
127 ...(options.includeTimestamps
128 ? [`<span>Created: ${new Date(conv.createdAt).toLocaleString()}</span>`]
129 : []),
130 `<span>Exported: ${new Date().toLocaleString()}</span>`,
131 ];
132
133 const messagesHtml = messages
134 .map((m) => renderMessageHtml(m, options))
135 .join("\n");
136
137 return `<!DOCTYPE html>
138<html lang="en">
139<head>
140 <meta charset="UTF-8" />
141 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
142 <title>${escapeHtml(conv.title)} — Claude Code</title>
143 <style>${CSS}</style>
144</head>
145<body>
146 <h1>${escapeHtml(conv.title)}</h1>
147 <div class="meta">${metaParts.join("")}</div>
148 <div class="messages">${messagesHtml}</div>
149 <div class="footer">
150 <a href="https://claude.ai/code">Powered by Claude Code</a>
151 </div>
152</body>
153</html>`;
154}

Callers 1

POSTFunction · 0.90

Calls 2

renderMessageHtmlFunction · 0.85
escapeHtmlFunction · 0.70

Tested by

no test coverage detected