A lightweight VS Code extension that renders LaTeX mathematical expressions directly inside Python IntelliSense hover tooltips—augmenting Pylance without replacing existing type signatures or documentation formatting.
Features
Inline Math:$...$, \(...\), and Sphinx/reStructuredText :math:`...` .
Language Server Integration: Extracts exact raw LaTeX from Python docstrings via Go-to-Definition (falling back to existing hover Markdown from Pylance or other Python language servers when needed) without replacing type signatures or documentation.
Unobtrusive: Returns no extra hover content when a docstring contains no LaTeX, and skips inline code spans, fenced code blocks, doctests (>>>), and currency heuristics ($10–$20).
Theme-Aware SVGs: Renders crisp, self-contained SVGs via lazy-loaded MathJax (mathjax-full) using VS Code's default hover text color on a transparent background.
Graceful Fallback: Malformed or unsupported LaTeX falls back to raw code formatting without breaking valid expressions in the same docstring.
Zero Python Dependencies: Runs entirely inside the VS Code extension host with an in-memory LRU render cache.
Extension Settings
Setting
Type
Default
Description
pythonLatexDocstring.enabled
boolean
true
Enable or disable LaTeX rendering in Python hover tooltips.
pythonLatexDocstring.displayMode
"full" \| "mathOnly"
"full"
Show the full formatted docstring with math rendered in-place (full) or only the rendered math expressions (mathOnly).
pythonLatexDocstring.foregroundColor
string
""
Override SVG foreground text color (e.g. #d4d4d4). Empty auto-detects from the active VS Code theme.
pythonLatexDocstring.backgroundColor
string
""
Override SVG background color (e.g. #1e1e1e). Empty uses a transparent background.
pythonLatexDocstring.scale
number
1.0
Scale factor applied to rendered math SVGs (0.5–3.0).
pythonLatexDocstring.showErrorHint
boolean
true
Show a subtle *(LaTeX error)* hint next to malformed expressions that fall back to raw text.
Development
# Type-check, lint, and bundle
npm run compile
# Run fast pure-TypeScript unit tests (Mocha)
npm run test:unit
# Run VS Code extension host integration tests
npm test
# Build production bundle
npm run package