Repository guidance for coding agents working in this workspace.
This repository contains a VS Code extension named latex-math-preview.
It provides:
- a math preview panel for LaTeX and Markdown
- LaTeX-Workshop-inspired TeX math detection
- Markdown math detection for
$...$,$$...$$,\(...\),\[...\] - MathJax rendering through a worker
- optional cursor rendering inside the preview
src/extension.ts: activation and command registrationsrc/preview/mathPreviewPanel.ts: panel lifecycle, serializer, refresh logicsrc/extract/: TeX and Markdown math extractionsrc/render/: preprocessing, cursor insertion, MathJax servicesrc/test/unit/: Vitest unit testssrc/test/suite/: VS Code integration testsmedia/mathpreview.js: webview script
- Keep the extension namespace as
latex-math-preview.*. - Preserve the existing split between extraction, rendering, panel control, and tests.
- Use native webview resource URIs. Do not add an internal HTTP asset server unless explicitly required.
- Prefer matching LaTeX-Workshop behavior for TeX math handling unless the repo already documents a deliberate deviation.
- Keep math detection and cursor rendering behavior internally consistent, predictable, and backed by tests rather than scattered special cases.
- Store document positions in the shared
Pointtype fromsrc/text-model.tsinstead of ad hoc{ line, character }object types. - Keep unit tests pure where possible; avoid pulling
vscodeinto unit-only modules.
- Install dependencies:
npm install - Compile:
npm run compile - Unit tests:
npm run test:unit - Integration tests:
npm run test:integration - Full test run:
npm test
- Integration tests use
@vscode/test-electron. - The test runner is configured to use short
/tmppaths for user/extensions dirs to avoid macOS socket path-length failures. - If integration tests fail because the VS Code test host is missing, rerun with network access enabled.
- If you change extraction behavior, update both TeX/Markdown tests and any affected integration coverage.
- If you change detection or cursor-placement rules, update implementation, tests, and repository guidance together so behavior and documentation do not drift.
- If you change panel update timing or cursor behavior, verify debounce behavior and selection/edit-triggered refreshes.
- If you change MathJax worker wiring, re-run compile plus both test suites.
- Avoid broad refactors unless they materially improve correctness or maintainability.