(conv: Conversation, options: ExportOptions)
| 47 | } |
| 48 | |
| 49 | export function toMarkdown(conv: Conversation, options: ExportOptions): string { |
| 50 | const lines: string[] = [ |
| 51 | `# ${conv.title}`, |
| 52 | "", |
| 53 | "---", |
| 54 | ...(options.includeTimestamps |
| 55 | ? [`**Created:** ${new Date(conv.createdAt).toISOString()}`] |
| 56 | : []), |
| 57 | ...(conv.model ? [`**Model:** ${conv.model}`] : []), |
| 58 | `**Messages:** ${conv.messages.length}`, |
| 59 | "---", |
| 60 | "", |
| 61 | ]; |
| 62 | |
| 63 | let messages = conv.messages; |
| 64 | if (options.dateRange) { |
| 65 | const { start, end } = options.dateRange; |
| 66 | messages = messages.filter((m) => m.createdAt >= start && m.createdAt <= end); |
| 67 | } |
| 68 | |
| 69 | for (const msg of messages) { |
| 70 | lines.push(renderMessage(msg, options)); |
| 71 | lines.push(""); |
| 72 | } |
| 73 | |
| 74 | lines.push("---"); |
| 75 | lines.push("*Exported from Claude Code*"); |
| 76 | |
| 77 | return lines.join("\n"); |
| 78 | } |
no test coverage detected