How arronhc/text2math works
Text2Math is an Obsidian plugin that converts selected or entered natural-language math descriptions into LaTeX, previews and validates the result, then replaces the selection or inserts at the cursor. The main.ts excerpt shows command/context-menu entry points, API invocation, preview dispatch, and editor commit; API, settings, and cleanup relationships are also supported by excerpts. README capabilities fill in documented mobile use and provider compatibility. The graph omits unsampled internals beyond those documented relationships.
Main entry points: main.ts Conversion coordinator · api.ts AI API client · modals.ts Formula preview · settings.ts Plugin settings
Components 12
Conversion workflow
- Commands and menu
src/main.ts - Conversion coordinator
src/main.ts - Markdown editor
Input and preview
- Description input
src/modals.ts - Formula preview
src/modals.ts - Math rendering
src/modals.ts
API and configuration
- AI API client
src/api.ts - Settings interface
src/settingTab.ts - Plugin settings
src/settings.ts
Formula processing
- LaTeX processing
src/clean.ts
Other components
- Obsidian user
- OpenAI-compatible API
Connections 18
- Obsidian user → Commands and menu: invokes
README.md - Commands and menu → Markdown editor: reads selection
src/main.ts - Commands and menu → Conversion coordinator: starts flow
src/main.ts - Commands and menu → Description input: opens when empty
src/main.ts - Description input → Conversion coordinator: submits description
src/main.ts - Conversion coordinator → AI API client: requests formula
src/main.ts - AI API client → OpenAI-compatible API: sends request
src/api.ts - OpenAI-compatible API → AI API client: returns completion
- AI API client → LaTeX processing: cleans and classifies
src/api.ts - Conversion coordinator → LaTeX processing: applies letter case
src/main.ts - Conversion coordinator → Formula preview: opens preview
src/main.ts - Formula preview → Math rendering: renders formula
src/modals.ts - Formula preview → Conversion coordinator: confirms or regenerates
src/main.ts - Conversion coordinator → Markdown editor: replaces or inserts
src/main.ts - Settings interface → AI API client: fetches models or tests
src/settingTab.ts - Settings interface → Plugin settings: updates settings
src/settingTab.ts - Conversion coordinator → Plugin settings: reads preferences
src/main.ts - AI API client → Plugin settings: reads API options
src/api.ts