$npx -y skills add NatsuFox/Tapestry --skill exportExport knowledge base content to PDF, Markdown, or HTML files saved under _data/exports/. Use when a user wants to save or share KB content as downloadable files. Supports exporting a single document file, a single feed entry, a single note, or the entire knowledge base.
| 1 | # Tapestry Export |
| 2 | |
| 3 | Export knowledge base content to portable file formats: **$ARGUMENTS** |
| 4 | |
| 5 | ## When to use this skill |
| 6 | |
| 7 | Use this skill when: |
| 8 | - A user wants to export, save, download, or share knowledge base content |
| 9 | - The user asks for a PDF, Markdown, or HTML version of a document or the whole KB |
| 10 | - The user wants offline-readable files from the knowledge base |
| 11 | - The user wants to share a chapter or article outside the viewer |
| 12 | |
| 13 | ## Arguments |
| 14 | |
| 15 | The argument string may contain any combination of: |
| 16 | |
| 17 | - **format**: `pdf`, `markdown`, `html`, or `all` (default: `all`) |
| 18 | - **scope**: `file`, `note`, `feed`, or `kb` (default: `kb`) |
| 19 | - **target**: a path or partial path to the target artifact (required for `file`, `note`, `feed` scopes) |
| 20 | |
| 21 | Examples: |
| 22 | - `"pdf kb"` — export the entire knowledge base as PDF |
| 23 | - `"html file _data/books/ai/chapter.md"` — export one document as HTML |
| 24 | - `"all note _data/notes/2025/03/my-note.md"` — export one note in all three formats |
| 25 | - `"markdown feed _data/feeds/2025/03/abc123.json"` — export one feed entry as Markdown |
| 26 | |
| 27 | ## Scope Resolution |
| 28 | |
| 29 | | Scope | Source files | Notes | |
| 30 | |---|---|---| |
| 31 | | `file` | Single `.md` file under `_data/books/` | Path provided by user | |
| 32 | | `note` | Single `.md` file under `_data/notes/` | Path provided by user | |
| 33 | | `feed` | Single `.json` file under `_data/feeds/` | Exports the `body` field as Markdown | |
| 34 | | `kb` | All `.md` files under `_data/books/` recursively | Entire knowledge base | |
| 35 | |
| 36 | ## Workflow |
| 37 | |
| 38 | 1. Parse the argument to determine format, scope, and target. |
| 39 | 2. Change to the project root directory. |
| 40 | 3. Run the export script: |
| 41 | |
| 42 | ```bash |
| 43 | # Export entire KB as PDF |
| 44 | python export/_scripts/export.py --format pdf --scope kb |
| 45 | |
| 46 | # Export entire KB in all formats |
| 47 | python export/_scripts/export.py --format all --scope kb |
| 48 | |
| 49 | # Export a single document as HTML |
| 50 | python export/_scripts/export.py --format html --scope file --target _data/books/topic/chapter/doc.md |
| 51 | |
| 52 | # Export a single note as Markdown |
| 53 | python export/_scripts/export.py --format markdown --scope note --target _data/notes/2025/03/note.md |
| 54 | |
| 55 | # Export a single feed entry in all formats |
| 56 | python export/_scripts/export.py --format all --scope feed --target _data/feeds/2025/03/abc123.json |
| 57 | ``` |
| 58 | |
| 59 | 4. The script prints a JSON summary of all exported file paths to stdout. |
| 60 | 5. Report the output paths back to the user. |
| 61 | |
| 62 | ## Output Location |
| 63 | |
| 64 | All exported files are saved under `_data/exports/`: |
| 65 | |
| 66 | ``` |
| 67 | _data/exports/ |
| 68 | markdown/ ← .md files |
| 69 | html/ ← standalone .html files (self-contained, with embedded images) |
| 70 | pdf/ ← .pdf files (requires playwright) |
| 71 | ``` |
| 72 | |
| 73 | File names mirror the source path structure. For example: |
| 74 | `_data/books/ai/chapter/doc.md` → `_data/exports/html/ai/chapter/doc.html` |
| 75 | |
| 76 | ## PDF Export Notes |
| 77 | |
| 78 | PDF export uses Playwright (headless Chromium) to render the HTML to PDF. |
| 79 | If Playwright is not installed, the script falls back to saving a self-printing HTML file |
| 80 | (with `window.onload = window.print()`) and will notify the user to open it in a browser |
| 81 | and use Print → Save as PDF. |
| 82 | |
| 83 | To install Playwright: |
| 84 | ```bash |
| 85 | pip install playwright && playwright install chromium |
| 86 | ``` |
| 87 | |
| 88 | ## Rich Text Handling |
| 89 | |
| 90 | - **Math (KaTeX)**: All exported HTML files include KaTeX CDN scripts for math rendering. |
| 91 | - **Images**: Images are base64-encoded and embedded inline in HTML/PDF exports for full portability. |
| 92 | - **Code blocks**: Syntax-highlighted HTML is preserved from the knowledge base renderer. |
| 93 | - **Tables**: Standard HTML tables are preserved. |
| 94 | |
| 95 | ## Resources |
| 96 | |
| 97 | - `export/_scripts/export.py`: Main export script. |
| 98 | - `display/_scripts/publish_viewer.py`: Provides `render_markdown_document()` used for HTML rendering. |
| 99 | - `_src/config.py`: `TapestryConfig` for resolving project and data paths. |