export_chapter
Export BookStack wiki chapters to HTML, PDF, plain text, or markdown formats for sharing, archiving, or offline use.
Instructions
Export a chapter in various formats
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Chapter ID | |
| format | Yes | Export format |
Implementation Reference
- src/tools/content-tools.ts:649-668 (handler)The handler logic within handleContentTool function that executes the export_chapter tool by parsing id and format, then calling the appropriate BookStackClient export method based on format.case "export_chapter": { const id = parseInteger(args.id); const format = args.format; switch (format) { case "html": const html = await client.exportChapterHtml(id); return html; case "pdf": return "PDF export is binary data - use API directly for file download"; case "plaintext": const text = await client.exportChapterPlainText(id); return text; case "markdown": const markdown = await client.exportChapterMarkdown(id); return markdown; default: throw new Error(`Unsupported export format: ${format}`); } }
- src/tools/content-tools.ts:277-292 (schema)The Tool object definition including name, description, and inputSchema for the export_chapter tool.{ name: "export_chapter", description: "Export a chapter in various formats", inputSchema: { type: "object", properties: { id: { type: "number", description: "Chapter ID" }, format: { type: "string", enum: ["html", "pdf", "plaintext", "markdown"], description: "Export format", }, }, required: ["id", "format"], }, },
- src/index.ts:88-88 (registration)The export_chapter tool is listed in the contentToolNames array, which determines if handleContentTool is called for this tool."export_chapter",
- src/lib/bookstack-client.ts:170-175 (helper)Helper method in BookStackClient that performs the HTTP GET request to export chapter as HTML.async exportChapterHtml(id: number): Promise<string> { const response: AxiosResponse<string> = await this.api.get( `/chapters/${id}/export/html` ); return response.data; }
- src/lib/bookstack-client.ts:177-185 (helper)Helper method in BookStackClient that performs the HTTP GET request to export chapter as PDF (binary).async exportChapterPdf(id: number): Promise<Buffer> { const response: AxiosResponse<Buffer> = await this.api.get( `/chapters/${id}/export/pdf`, { responseType: "arraybuffer", } ); return response.data; }
- src/lib/bookstack-client.ts:187-192 (helper)Helper method in BookStackClient that performs the HTTP GET request to export chapter as plain text.async exportChapterPlainText(id: number): Promise<string> { const response: AxiosResponse<string> = await this.api.get( `/chapters/${id}/export/plaintext` ); return response.data; }
- src/lib/bookstack-client.ts:194-199 (helper)Helper method in BookStackClient that performs the HTTP GET request to export chapter as Markdown.async exportChapterMarkdown(id: number): Promise<string> { const response: AxiosResponse<string> = await this.api.get( `/chapters/${id}/export/markdown` ); return response.data; }