@laitszkin/apollo-toolkit 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -1
- package/CHANGELOG.md +11 -0
- package/README.md +2 -0
- package/document-vision-reader/LICENSE +21 -0
- package/document-vision-reader/README.md +66 -0
- package/document-vision-reader/SKILL.md +151 -0
- package/document-vision-reader/agents/openai.yaml +4 -0
- package/document-vision-reader/references/legibility-checklist.md +13 -0
- package/document-vision-reader/references/rendering-guide.md +37 -0
- package/katex/SKILL.md +92 -0
- package/katex/agents/openai.yaml +4 -0
- package/katex/references/insertion-patterns.md +54 -0
- package/katex/references/official-docs.md +35 -0
- package/katex/scripts/render_katex.py +247 -0
- package/katex/scripts/render_katex.sh +11 -0
- package/learning-error-book/SKILL.md +46 -31
- package/learning-error-book/agents/openai.yaml +2 -2
- package/learning-error-book/assets/long_question_reference_template.json +57 -0
- package/learning-error-book/assets/mc_question_reference_template.json +49 -0
- package/learning-error-book/scripts/render_error_book_json_to_pdf.py +590 -0
- package/package.json +1 -1
- package/learning-error-book/assets/error_book_template.md +0 -66
- package/learning-error-book/scripts/render_markdown_to_pdf.py +0 -367
package/AGENTS.md
CHANGED
|
@@ -31,7 +31,7 @@ This repository enables users to install and run a curated set of reusable agent
|
|
|
31
31
|
- Users can run evidence-first application security audits focused on confirmed vulnerabilities.
|
|
32
32
|
- Users can learn new or improved skills from recent Codex conversation history.
|
|
33
33
|
- Users can audit and maintain the skill catalog itself, including dependency classification and shared-skill extraction decisions.
|
|
34
|
-
- Users can summarize mistakes into
|
|
34
|
+
- Users can summarize mistakes into separate multiple-choice and long-answer error books backed by structured reference files and rendered PDFs.
|
|
35
35
|
- Users can build or review marginfi protocol integrations using official SDK, CLI, protocol, and The Arena documentation.
|
|
36
36
|
- Users can create or maintain `AGENTS.md` so project constraints stay aligned with the repository.
|
|
37
37
|
- Users can turn novel content into a loopable short-form video with generated assets.
|
|
@@ -48,6 +48,7 @@ This repository enables users to install and run a curated set of reusable agent
|
|
|
48
48
|
- Users can build and maintain Solana programs and Rust clients using official Solana development workflows.
|
|
49
49
|
- Users can add focused observability to opaque workflows through targeted logs, metrics, traces, and tests.
|
|
50
50
|
- Users can build against Jupiter's official Solana swap, token, price, lending, trigger, recurring, and portfolio APIs with an evidence-based development guide.
|
|
51
|
+
- Users can render and embed math formulas with KaTeX using official documentation-backed guidance and reusable rendering scripts.
|
|
51
52
|
- Users can debug software systematically by reproducing causes, validating fixes, and testing outcomes.
|
|
52
53
|
- Users can generate 30-60 second short videos directly from text prompts.
|
|
53
54
|
- Users can prepare and publish versioned releases with changelog and tag workflows.
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,17 @@ All notable changes to this repository are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [v2.10.0] - 2026-03-21
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Add `document-vision-reader` for screenshot-based inspection of rendered documents when visible layout matters more than raw extracted text.
|
|
11
|
+
- Add `katex` for rendering and embedding math formulas with official KaTeX guidance and reusable render scripts.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Rework `learning-error-book` to generate separate multiple-choice and long-answer reference JSON files plus polished PDFs rendered directly from structured data.
|
|
15
|
+
- Update the repository skill inventory and project capability docs to include the new document-vision and KaTeX workflows.
|
|
16
|
+
|
|
17
|
+
|
|
7
18
|
## [v2.9.0] - 2026-03-21
|
|
8
19
|
|
|
9
20
|
### Changed
|
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ A curated skill catalog for Codex, OpenClaw, and Trae with a managed installer t
|
|
|
14
14
|
- develop-new-features
|
|
15
15
|
- discover-edge-cases
|
|
16
16
|
- docs-to-voice
|
|
17
|
+
- document-vision-reader
|
|
17
18
|
- enhance-existing-features
|
|
18
19
|
- feature-propose
|
|
19
20
|
- financial-research
|
|
@@ -22,6 +23,7 @@ A curated skill catalog for Codex, OpenClaw, and Trae with a managed installer t
|
|
|
22
23
|
- harden-app-security
|
|
23
24
|
- improve-observability
|
|
24
25
|
- jupiter-development
|
|
26
|
+
- katex
|
|
25
27
|
- learn-skill-from-conversations
|
|
26
28
|
- learning-error-book
|
|
27
29
|
- marginfi-development
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 LaiTszKin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Document Vision Reader
|
|
2
|
+
|
|
3
|
+
A visual-reading skill for non-plain-text files that should be checked from their rendered appearance instead of raw text extraction.
|
|
4
|
+
|
|
5
|
+
## What this skill does
|
|
6
|
+
|
|
7
|
+
- Creates a temporary screenshot workspace for the target file.
|
|
8
|
+
- Converts or captures the requested pages/regions into temporary images.
|
|
9
|
+
- Reads those images as the evidence source.
|
|
10
|
+
- Answers user requests such as summaries, transcription, field lookup, table extraction, comparison, and translation from the visible content.
|
|
11
|
+
- Cleans up temporary screenshots by default after the answer is prepared.
|
|
12
|
+
|
|
13
|
+
## Best-fit use cases
|
|
14
|
+
|
|
15
|
+
- scanned PDFs
|
|
16
|
+
- rendered PDF files
|
|
17
|
+
- rendered PPT/PPTX slides
|
|
18
|
+
- receipts, invoices, and forms
|
|
19
|
+
- slide decks with annotations or visual emphasis
|
|
20
|
+
- documents where highlights, layout, handwriting, or stamps matter
|
|
21
|
+
- spreadsheets where merged cells or formatting affect meaning
|
|
22
|
+
- files whose text extraction is unreliable
|
|
23
|
+
- not plain-text files whose meaning depends on visual rendering
|
|
24
|
+
|
|
25
|
+
## Repository layout
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
.
|
|
29
|
+
├── SKILL.md
|
|
30
|
+
├── README.md
|
|
31
|
+
├── LICENSE
|
|
32
|
+
├── agents/
|
|
33
|
+
│ └── openai.yaml
|
|
34
|
+
└── references/
|
|
35
|
+
├── legibility-checklist.md
|
|
36
|
+
└── rendering-guide.md
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
Use $document-vision-reader to inspect this non-plain-text file by turning its rendered pages into temporary screenshots, reading the screenshots as images, and answering from the visible content only.
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Example requests:
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
Use $document-vision-reader to inspect pages 3-5 of this scanned PDF, extract the totals table, and flag any handwritten notes.
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
Use $document-vision-reader to capture the rendered slides of this PPTX as temporary screenshots, read them visually, and tell me whether the key metrics on slide 7 match slide 12.
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Output expectations
|
|
56
|
+
|
|
57
|
+
A good result should include:
|
|
58
|
+
|
|
59
|
+
1. the direct answer to the user's request
|
|
60
|
+
2. which screenshots/pages were used
|
|
61
|
+
3. any visibility limits or unreadable regions
|
|
62
|
+
4. whether the temporary screenshot directory was removed or preserved
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MIT. See `LICENSE`.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: document-vision-reader
|
|
3
|
+
description: Convert rendered non-plain-text files into temporary screenshots, inspect those screenshots as images, and answer the user's request from the visible visual output. Use when an agent needs to inspect PDFs, PPT/PPTX decks, scanned documents, forms, spreadsheets, or other files whose rendered appearance matters more than raw text extraction.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Document Vision Reader
|
|
7
|
+
|
|
8
|
+
## Dependencies
|
|
9
|
+
|
|
10
|
+
- Required: none.
|
|
11
|
+
- Conditional: `screenshot` when the host needs OS-level captures; `pdf`, `doc`, `pptx`, or `spreadsheet` when the source file needs format-specific rendering before screenshot capture.
|
|
12
|
+
- Optional: none.
|
|
13
|
+
- Fallback: If the file cannot be rendered or captured safely, ask the user for the relevant screenshots/pages instead of guessing from inaccessible content.
|
|
14
|
+
|
|
15
|
+
## Standards
|
|
16
|
+
|
|
17
|
+
- Evidence: Base every conclusion on visible screenshot content only; call out blur, clipping, hidden areas, and unreadable regions explicitly.
|
|
18
|
+
- Execution: Create a temporary screenshot workspace, capture only the pages/regions needed, inspect the images, answer the request, and remove temporary artifacts unless the user asked to keep them.
|
|
19
|
+
- Quality: Prefer legible crops over full-page miniatures, keep screenshot naming deterministic, and verify that every requested page or region was actually reviewed.
|
|
20
|
+
- Output: Return the user-facing answer plus the screenshot coverage used, any visibility limits, and whether temporary files were cleaned up.
|
|
21
|
+
|
|
22
|
+
## Goal
|
|
23
|
+
|
|
24
|
+
Use visual reading as the source of truth when the target file is not a plain-text artifact and the rendered appearance matters more than extractable text.
|
|
25
|
+
|
|
26
|
+
Typical cases:
|
|
27
|
+
|
|
28
|
+
- scanned PDFs or image-only files
|
|
29
|
+
- PDF reports, statements, and forms
|
|
30
|
+
- PPT/PPTX slides that must be checked as rendered pages
|
|
31
|
+
- forms, receipts, invoices, and reports with layout cues
|
|
32
|
+
- slides or documents where comments, highlights, colors, callouts, or alignment matter
|
|
33
|
+
- spreadsheets where merged cells, visual grouping, or formatting affects interpretation
|
|
34
|
+
- cases where raw text extraction is incomplete, broken, or misleading
|
|
35
|
+
|
|
36
|
+
Do not use this skill for plain-text files when normal text reading is sufficient.
|
|
37
|
+
|
|
38
|
+
## Workflow
|
|
39
|
+
|
|
40
|
+
### 1) Confirm scope and output target
|
|
41
|
+
|
|
42
|
+
Before capturing anything, determine:
|
|
43
|
+
|
|
44
|
+
- which file or files must be inspected
|
|
45
|
+
- what the user actually needs (summary, transcription, table extraction, comparison, QA, translation, field lookup, etc.)
|
|
46
|
+
- which pages, slides, sheets, or regions matter most
|
|
47
|
+
- whether the user needs the temporary screenshots returned or only used internally
|
|
48
|
+
|
|
49
|
+
If the file is long, capture only the requested pages or the smallest range needed to answer correctly.
|
|
50
|
+
|
|
51
|
+
### 2) Create a temporary screenshot workspace
|
|
52
|
+
|
|
53
|
+
Create a dedicated temporary directory, for example:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
TMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/document-vision-reader.XXXXXX")"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Inside that directory, keep deterministic names such as:
|
|
60
|
+
|
|
61
|
+
- `page-001.png`
|
|
62
|
+
- `page-002-top.png`
|
|
63
|
+
- `slide-004-notes.png`
|
|
64
|
+
- `sheet-budget-row-01.png`
|
|
65
|
+
|
|
66
|
+
Do not write temporary screenshots into the user's project unless they explicitly ask for that.
|
|
67
|
+
|
|
68
|
+
### 3) Render the document into screenshots
|
|
69
|
+
|
|
70
|
+
Use the most reliable renderer available for the source format.
|
|
71
|
+
|
|
72
|
+
- PDFs or scans: render requested pages to images first, then inspect those images.
|
|
73
|
+
- DOCX/PPTX/XLSX and similar office files: open a rendered view and capture screenshots from the visual output rather than trusting raw XML/text extraction.
|
|
74
|
+
- Existing images: copy or convert into a readable PNG/JPEG only when needed.
|
|
75
|
+
- Large pages or dense tables: use multiple crops instead of shrinking the entire page until text becomes unreadable.
|
|
76
|
+
|
|
77
|
+
Prefer format-specific helper skills when they improve rendering fidelity:
|
|
78
|
+
|
|
79
|
+
- `pdf` for PDF page handling
|
|
80
|
+
- `doc` for Word-like documents
|
|
81
|
+
- `pptx` for slides
|
|
82
|
+
- `spreadsheet` for sheets/tables
|
|
83
|
+
- `screenshot` for OS-level capture when no direct renderer is available
|
|
84
|
+
|
|
85
|
+
If rendering tooling is missing, stop and ask for the minimal set of screenshots or pages needed.
|
|
86
|
+
|
|
87
|
+
### 4) Verify screenshot legibility before reading
|
|
88
|
+
|
|
89
|
+
Check every capture before extracting facts.
|
|
90
|
+
|
|
91
|
+
- Zoom or recapture if body text is not comfortably readable.
|
|
92
|
+
- Split one dense page into multiple overlapping crops when needed.
|
|
93
|
+
- Keep labels, units, headers, and nearby notes in frame so interpretation stays grounded.
|
|
94
|
+
- If a section is truncated or hidden, do not infer the missing content.
|
|
95
|
+
|
|
96
|
+
Use `references/legibility-checklist.md` when a page is crowded or the answer depends on small details.
|
|
97
|
+
|
|
98
|
+
### 5) Read screenshots as images
|
|
99
|
+
|
|
100
|
+
Read the screenshots with image-capable tools only after the captures are ready.
|
|
101
|
+
|
|
102
|
+
- Inspect the actual rendered content, not an assumed underlying text layer.
|
|
103
|
+
- Treat handwriting, highlights, annotations, stamps, signatures, and color coding as first-class evidence when visible.
|
|
104
|
+
- For tables, verify row/column alignment from the image before extracting values.
|
|
105
|
+
- For multi-page answers, track which screenshot supports each claim.
|
|
106
|
+
|
|
107
|
+
When the answer depends on multiple screenshots, reconcile them explicitly instead of paraphrasing from memory.
|
|
108
|
+
|
|
109
|
+
### 6) Answer the user's request
|
|
110
|
+
|
|
111
|
+
In the response:
|
|
112
|
+
|
|
113
|
+
- answer the requested task directly
|
|
114
|
+
- note which screenshots/pages were used
|
|
115
|
+
- call out any uncertain or unreadable sections
|
|
116
|
+
- distinguish visible facts from interpretation
|
|
117
|
+
|
|
118
|
+
If the user asked for extraction, structure the output so it can be checked against the screenshots.
|
|
119
|
+
|
|
120
|
+
### 7) Clean up temporary files
|
|
121
|
+
|
|
122
|
+
After the answer is prepared:
|
|
123
|
+
|
|
124
|
+
- delete the temporary screenshot directory by default
|
|
125
|
+
- keep it only when the user explicitly wants the screenshots, a reusable artifact, or a debugging trail
|
|
126
|
+
- if cleanup fails, report the leftover path so it can be removed later
|
|
127
|
+
|
|
128
|
+
## Decision Rules
|
|
129
|
+
|
|
130
|
+
- Prefer screenshot reading whenever visual layout changes meaning.
|
|
131
|
+
- Prefer this skill for rendered non-plain-text files such as PDF and PPT/PPTX.
|
|
132
|
+
- Do not use this skill when a plain-text source can be read directly without losing meaning.
|
|
133
|
+
- Prefer the smallest sufficient capture set; avoid screenshotting an entire long document when the user only asked about one section.
|
|
134
|
+
- Prefer multiple readable crops over one unreadable full-page image.
|
|
135
|
+
- Never invent text hidden outside the visible capture.
|
|
136
|
+
- If screenshots and extracted text disagree, trust the visible screenshot and mention the mismatch.
|
|
137
|
+
|
|
138
|
+
## Output Checklist
|
|
139
|
+
|
|
140
|
+
Before finishing, confirm all of the following:
|
|
141
|
+
|
|
142
|
+
- the requested pages/regions were actually captured
|
|
143
|
+
- the screenshots were legible enough for the requested task
|
|
144
|
+
- the final answer is grounded in visible content
|
|
145
|
+
- uncertainty or occlusion is disclosed
|
|
146
|
+
- temporary artifacts were deleted or intentionally preserved
|
|
147
|
+
|
|
148
|
+
## Resources
|
|
149
|
+
|
|
150
|
+
- `references/rendering-guide.md`: format-by-format screenshot staging guidance.
|
|
151
|
+
- `references/legibility-checklist.md`: quick quality gate for readable visual extraction.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "Document Vision Reader"
|
|
3
|
+
short_description: "Read rendered PDF/PPT-like files through temporary screenshots"
|
|
4
|
+
default_prompt: "Use $document-vision-reader when I need to inspect a non-plain-text rendered file such as PDF or PPT/PPTX, create temporary screenshots for the relevant pages or regions, inspect those screenshots as images instead of trusting raw text extraction, answer from visible content only, and clean up the temporary screenshot workspace unless I ask to keep it."
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Legibility Checklist
|
|
2
|
+
|
|
3
|
+
Before answering from screenshots, confirm:
|
|
4
|
+
|
|
5
|
+
- text is readable without guessing
|
|
6
|
+
- important numbers and decimal places are visible
|
|
7
|
+
- row and column boundaries are clear for tables
|
|
8
|
+
- annotations, highlights, stamps, and signatures are not clipped
|
|
9
|
+
- the capture includes enough surrounding context to interpret the target content
|
|
10
|
+
- overlapping crops cover any area split across captures
|
|
11
|
+
- page or slide identity is trackable from the filename or nearby context
|
|
12
|
+
|
|
13
|
+
If any item fails, recapture before answering.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Rendering Guide
|
|
2
|
+
|
|
3
|
+
Use the smallest reliable rendering path that preserves what the user needs to inspect.
|
|
4
|
+
|
|
5
|
+
## PDF or scanned document
|
|
6
|
+
|
|
7
|
+
- Capture only the requested pages first.
|
|
8
|
+
- If a full page becomes unreadable when scaled down, split it into overlapping crops.
|
|
9
|
+
- Preserve headers, footers, totals, and marginal notes when they affect interpretation.
|
|
10
|
+
|
|
11
|
+
## DOCX or rich-text document
|
|
12
|
+
|
|
13
|
+
- Read from a rendered page view, not raw XML text.
|
|
14
|
+
- Preserve comments, highlights, tracked-style decorations, and side notes when visible.
|
|
15
|
+
- Capture section-by-section when the page is text dense.
|
|
16
|
+
|
|
17
|
+
## PPTX or slide deck
|
|
18
|
+
|
|
19
|
+
- Capture slide canvases at a readable scale.
|
|
20
|
+
- Include presenter notes only if the user asks for them or they are needed to answer.
|
|
21
|
+
- When diagrams are dense, take one full-slide capture plus zoomed crops for detailed regions.
|
|
22
|
+
|
|
23
|
+
## Spreadsheet
|
|
24
|
+
|
|
25
|
+
- Keep row labels, column headers, and units visible in the same capture.
|
|
26
|
+
- Use overlapping viewport captures for wide tables.
|
|
27
|
+
- If color coding or conditional formatting matters, mention it explicitly in the answer.
|
|
28
|
+
|
|
29
|
+
## Existing image file
|
|
30
|
+
|
|
31
|
+
- Reuse the original image when it is already readable.
|
|
32
|
+
- Convert only when the target tool requires a different format.
|
|
33
|
+
|
|
34
|
+
## General fallback
|
|
35
|
+
|
|
36
|
+
- If no reliable renderer is available, ask the user for the specific screenshots needed.
|
|
37
|
+
- Do not claim coverage for pages or regions that were never captured.
|
package/katex/SKILL.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: katex
|
|
3
|
+
description: Render and embed math formulas with KaTeX using official documentation-backed patterns. Use when an agent needs inline or display math in HTML, Markdown, MDX, or other text-based outputs, or when it should generate insertion-ready KaTeX snippets from TeX.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# KaTeX
|
|
7
|
+
|
|
8
|
+
## Dependencies
|
|
9
|
+
|
|
10
|
+
- Required: none.
|
|
11
|
+
- Conditional: none.
|
|
12
|
+
- Optional: none.
|
|
13
|
+
- Fallback: If `node`, `npx`, or network package download is unavailable, keep the source TeX unchanged and explain that KaTeX rendering could not be generated locally.
|
|
14
|
+
|
|
15
|
+
## Standards
|
|
16
|
+
|
|
17
|
+
- Evidence: Follow the official KaTeX docs in `references/official-docs.md` before choosing render mode, options, or insertion strategy.
|
|
18
|
+
- Execution: Decide between pre-rendering and client-side auto-render first, then use `scripts/render_katex.py` for deterministic output whenever a static rendered snippet is enough.
|
|
19
|
+
- Quality: Default to `htmlAndMathml`, keep `trust` disabled unless the content source is explicitly trusted, and include the KaTeX stylesheet whenever the output will be displayed in HTML.
|
|
20
|
+
- Output: Return insertion-ready content plus the exact CSS or runtime requirements still needed by the target file.
|
|
21
|
+
|
|
22
|
+
## Goal
|
|
23
|
+
|
|
24
|
+
Use KaTeX safely and consistently so mathematical formulas can be inserted into documents without the agent re-deriving the rendering workflow each time.
|
|
25
|
+
|
|
26
|
+
## Workflow
|
|
27
|
+
|
|
28
|
+
### 1) Confirm the target surface
|
|
29
|
+
|
|
30
|
+
- Identify the destination file type before rendering: static HTML, Markdown/MDX, generated docs, or an existing HTML page that already contains TeX delimiters.
|
|
31
|
+
- Decide whether the destination can keep raw HTML. If it cannot, keep the TeX source and document the runtime rendering requirement instead of forcing a broken snippet.
|
|
32
|
+
|
|
33
|
+
### 2) Pick the right rendering strategy
|
|
34
|
+
|
|
35
|
+
- Use **pre-rendering** when the agent needs a stable snippet to paste into HTML, Markdown, MDX, templates, or generated artifacts.
|
|
36
|
+
- Use **auto-render** only when the document should keep TeX delimiters in source and render in the browser at runtime.
|
|
37
|
+
- Prefer pre-rendering for one-off formulas and exported documents. Prefer auto-render when the file intentionally stores author-friendly TeX like `$...$` and `$$...$$`.
|
|
38
|
+
|
|
39
|
+
### 3) Render static output with the bundled script
|
|
40
|
+
|
|
41
|
+
Run the bundled renderer for pre-rendered output:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
python3 katex/scripts/render_katex.py \
|
|
45
|
+
--tex '\int_0^1 x^2 \\, dx = \\frac{1}{3}' \
|
|
46
|
+
--display-mode \
|
|
47
|
+
--output-format html-fragment
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Useful output modes:
|
|
51
|
+
|
|
52
|
+
- `html-fragment`: paste into HTML, MDX, JSX, or Markdown engines that allow raw HTML.
|
|
53
|
+
- `html-page`: generate a standalone previewable HTML file with the KaTeX stylesheet link included.
|
|
54
|
+
- `markdown-inline`: emit an inline-friendly HTML fragment for Markdown/MDX.
|
|
55
|
+
- `markdown-block`: emit a block-friendly HTML fragment for Markdown/MDX.
|
|
56
|
+
- `json`: emit machine-friendly JSON for downstream automation or templating.
|
|
57
|
+
|
|
58
|
+
Useful options:
|
|
59
|
+
|
|
60
|
+
- `--display-mode` for centered display math; omit for inline math.
|
|
61
|
+
- `--katex-format htmlAndMathml` by default for accessibility; switch only when the destination needs HTML-only or MathML-only output.
|
|
62
|
+
- `--macro` / `--macro-file` for reusable custom macros.
|
|
63
|
+
- `--strict`, `--trust`, `--max-size`, `--max-expand`, `--error-color`, and `--no-throw-on-error` when the task needs explicit control from the official options reference.
|
|
64
|
+
|
|
65
|
+
### 4) Insert output according to file type
|
|
66
|
+
|
|
67
|
+
- **HTML / template files**: paste `html-fragment` output and ensure the page loads the KaTeX stylesheet.
|
|
68
|
+
- **Standalone HTML exports**: use `html-page` when the user wants a ready-to-open preview file.
|
|
69
|
+
- **Markdown / MDX**: use `markdown-inline` or `markdown-block` only if the target renderer preserves raw HTML; otherwise keep source TeX and document the runtime render requirement.
|
|
70
|
+
- **Existing browser pages with raw delimiters**: keep the original TeX and wire in the official auto-render assets instead of pasting a pre-rendered snippet.
|
|
71
|
+
|
|
72
|
+
See `references/insertion-patterns.md` for concrete insertion guidance.
|
|
73
|
+
|
|
74
|
+
### 5) Apply the official runtime requirements
|
|
75
|
+
|
|
76
|
+
- KaTeX-rendered HTML needs the KaTeX CSS to display correctly.
|
|
77
|
+
- Official docs recommend using the HTML5 doctype so browser quirks mode does not distort layout.
|
|
78
|
+
- For browser auto-render, load `katex.min.js`, `auto-render.min.js`, the stylesheet, then call `renderMathInElement(...)` after the DOM is ready.
|
|
79
|
+
|
|
80
|
+
### 6) Keep safety and maintainability defaults
|
|
81
|
+
|
|
82
|
+
- Keep `trust` off unless the input source is trusted and the task explicitly needs trusted commands.
|
|
83
|
+
- On untrusted content, keep size and expansion limits bounded instead of relaxing them blindly.
|
|
84
|
+
- Reuse one macro definition source across the whole document when many formulas share the same commands.
|
|
85
|
+
- When the rendered output is only for preview and the final destination has its own KaTeX pipeline, prefer editing the TeX source instead of freezing rendered HTML too early.
|
|
86
|
+
|
|
87
|
+
## References
|
|
88
|
+
|
|
89
|
+
- `references/official-docs.md`: condensed notes from the official KaTeX docs and direct source links.
|
|
90
|
+
- `references/insertion-patterns.md`: insertion patterns for HTML, Markdown/MDX, and auto-rendered pages.
|
|
91
|
+
- `scripts/render_katex.py`: deterministic wrapper around the official KaTeX CLI for insertion-ready output.
|
|
92
|
+
- `scripts/render_katex.sh`: shell wrapper for environments that prefer an executable script entrypoint.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: "KaTeX"
|
|
3
|
+
short_description: "Render and embed math formulas with KaTeX using insertion-ready snippets."
|
|
4
|
+
default_prompt: "Use $katex to turn TeX math into insertion-ready KaTeX output, choose between pre-rendering and auto-render based on the target file, and use the bundled renderer script when a static snippet or preview file is needed."
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# KaTeX Insertion Patterns
|
|
2
|
+
|
|
3
|
+
## HTML or template files
|
|
4
|
+
|
|
5
|
+
- Use:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
python3 katex/scripts/render_katex.py \
|
|
9
|
+
--tex 'E = mc^2' \
|
|
10
|
+
--output-format html-fragment
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
- Paste the output where the formula should appear.
|
|
14
|
+
- Ensure the destination page loads a KaTeX stylesheet such as the official CDN link.
|
|
15
|
+
|
|
16
|
+
## Standalone preview page
|
|
17
|
+
|
|
18
|
+
- Use:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
python3 katex/scripts/render_katex.py \
|
|
22
|
+
--tex '\\sum_{i=1}^{n} i = \\frac{n(n+1)}{2}' \
|
|
23
|
+
--display-mode \
|
|
24
|
+
--output-format html-page \
|
|
25
|
+
--output-file /absolute/path/preview.html
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- Open the generated file in a browser to visually confirm spacing and line breaking.
|
|
29
|
+
|
|
30
|
+
## Markdown or MDX that preserves raw HTML
|
|
31
|
+
|
|
32
|
+
- Use `markdown-inline` for inline formulas and `markdown-block` for display formulas.
|
|
33
|
+
- The result is still HTML. It works only when the downstream renderer keeps raw HTML intact.
|
|
34
|
+
- If the renderer sanitizes or escapes HTML, keep the source TeX instead of pasting the rendered fragment.
|
|
35
|
+
|
|
36
|
+
## Existing HTML page that stores raw TeX delimiters
|
|
37
|
+
|
|
38
|
+
- Keep the source TeX in the document.
|
|
39
|
+
- Load the official assets:
|
|
40
|
+
- `katex.min.css`
|
|
41
|
+
- `katex.min.js`
|
|
42
|
+
- `contrib/auto-render.min.js`
|
|
43
|
+
- Call `renderMathInElement(container, options)` after the DOM is ready.
|
|
44
|
+
- Restrict the container instead of rendering the whole page when only one section contains math.
|
|
45
|
+
|
|
46
|
+
## Shared macros across a document
|
|
47
|
+
|
|
48
|
+
- Put macros in a JSON file and pass `--macro-file`.
|
|
49
|
+
- Reuse the same macro definitions for every formula generated into the same document.
|
|
50
|
+
|
|
51
|
+
## Error-handling defaults
|
|
52
|
+
|
|
53
|
+
- Keep `throwOnError` enabled unless the task explicitly prefers graceful fallback rendering.
|
|
54
|
+
- When previewing user-supplied formulas that may be invalid, use `--no-throw-on-error` and keep the original TeX nearby for debugging.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Official KaTeX Docs Notes
|
|
2
|
+
|
|
3
|
+
These notes condense the official KaTeX documentation that was checked on 2026-03-21. Re-open the linked pages when exact behavior matters.
|
|
4
|
+
|
|
5
|
+
## Core pages
|
|
6
|
+
|
|
7
|
+
- [API](https://katex.org/docs/api.html)
|
|
8
|
+
- Browser rendering uses `katex.render`.
|
|
9
|
+
- String generation uses `katex.renderToString`.
|
|
10
|
+
- The docs recommend reusing the same `macros` object when multiple formulas should share macro definitions.
|
|
11
|
+
- [Options](https://katex.org/docs/options.html)
|
|
12
|
+
- `displayMode`, `output`, `throwOnError`, `errorColor`, `macros`, `minRuleThickness`, `colorIsTextColor`, `strict`, `trust`, `maxSize`, and `maxExpand` are the main rendering controls.
|
|
13
|
+
- `htmlAndMathml` is the default output mode and is the accessibility-friendly default.
|
|
14
|
+
- [Node.js](https://katex.org/docs/node)
|
|
15
|
+
- Include the KaTeX stylesheet when rendering HTML generated by `renderToString`.
|
|
16
|
+
- Use the HTML5 doctype to avoid browser quirks mode.
|
|
17
|
+
- Browser-side `katex.render` and server-side `renderToString` can share the same options.
|
|
18
|
+
- [CLI](https://katex.org/docs/cli)
|
|
19
|
+
- The official CLI accepts TeX from stdin or `--input`.
|
|
20
|
+
- Useful flags include `--display-mode`, `--format`, `--macro`, `--macro-file`, `--error-color`, `--no-throw-on-error`, `--leqno`, `--fleqn`, `--min-rule-thickness`, `--color-is-text-color`, `--strict`, `--trust`, `--max-size`, and `--max-expand`.
|
|
21
|
+
- [Auto-render extension](https://katex.org/docs/autorender.html)
|
|
22
|
+
- Load `auto-render.min.js` after `katex.min.js`.
|
|
23
|
+
- Call `renderMathInElement(document.body)` or scope it to a narrower container.
|
|
24
|
+
- The docs show default delimiters for block math and right-associative delimiter ordering.
|
|
25
|
+
- Ignored tags include `script`, `noscript`, `style`, `textarea`, `pre`, `code`, and `option`.
|
|
26
|
+
- [Supported Functions](https://katex.org/docs/supported)
|
|
27
|
+
- Use this page to confirm whether a command is supported before promising a render.
|
|
28
|
+
|
|
29
|
+
## Practical guidance extracted from the official docs
|
|
30
|
+
|
|
31
|
+
1. Prefer pre-rendered output when the agent is generating a static artifact.
|
|
32
|
+
2. Prefer auto-render only when the source document should remain human-editable TeX with delimiters.
|
|
33
|
+
3. Keep `trust` disabled by default.
|
|
34
|
+
4. Include the stylesheet for every HTML destination.
|
|
35
|
+
5. Keep one shared macro map across formulas when macro definitions are expected to persist.
|