Skip to content

Normalize math rendering in docs panel and LSP tooltips#8315

Open
LiquidGunay wants to merge 4 commits intomarimo-team:mainfrom
LiquidGunay:fix/math-rendering-docs-tooltips
Open

Normalize math rendering in docs panel and LSP tooltips#8315
LiquidGunay wants to merge 4 commits intomarimo-team:mainfrom
LiquidGunay:fix/math-rendering-docs-tooltips

Conversation

@LiquidGunay
Copy link

@LiquidGunay LiquidGunay commented Feb 14, 2026

📝 Summary

Fix math rendering consistency for docstrings shown in the Documentation panel and CodeMirror LSP tooltips.

🔍 Description of Changes

This PR normalizes math syntax in both rendering paths:

  • Backend docs path (completion_info) in marimo/_runtime/complete.py
  • Frontend LSP markdown docs path in frontend/src/core/codemirror/lsp/notebook-lsp.ts

Backend

  • Added internal docstring math normalization before markdown->HTML rendering.
  • Supported syntax:
    • .. math::
    • :math: inline role
    • $...$, $$...$$
    • \(...\), \[...\]
  • Preserves fenced code blocks and inline code spans.
  • Applied to normal docstring conversion and appended __init__ docstrings.

Frontend (LSP)

  • Added frontend/src/core/codemirror/lsp/normalize-markdown-math.ts.
  • Normalizes markdown math into <marimo-tex ...> while preserving fenced/inline code.
  • Also normalizes LSP MarkupContent docs returned as kind: plaintext when math markers are present by converting them to markdown for rendering.
  • Keeps non-math plaintext docs unchanged.
  • Applied in LSP client responses for:
    • hover
    • completion docs
    • completion item resolve docs
    • signature + parameter docs

Tests

  • Added backend tests in tests/_runtime/test_complete.py for math normalization and code-block safety.
  • Added frontend utility tests in frontend/src/core/codemirror/lsp/__tests__/normalize-markdown-math.test.ts.
    • Includes plaintext-math vs non-math plaintext behavior.
  • Extended LSP client tests in frontend/src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts.
    • Added regression coverage for plaintext completion docs containing .. math::.

Validation run

  • uvx hatch run +py=3.12 test:test tests/_runtime/test_complete.py
  • cd frontend && pnpm test src/core/codemirror/lsp/__tests__/notebook-lsp.test.ts src/core/codemirror/lsp/__tests__/normalize-markdown-math.test.ts

Screenshot

math-rendering-after math-rendering-after_1

📋 Checklist

  • I have read the contributor guidelines.
  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Tests have been added for the changes made.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Pull request title is a good summary of the changes - it will be used in the release notes.

@vercel
Copy link

vercel bot commented Feb 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Feb 14, 2026 9:33am

Request Review

@github-actions
Copy link

github-actions bot commented Feb 14, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@LiquidGunay
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

- Normalize math syntax in LSP MarkupContent docs even when kind=plaintext\n- Preserve non-math plaintext docs unchanged\n- Add regression tests for plaintext completion docs containing .. math::\n- Extend normalizeLspDocumentation tests for plaintext math vs literal dollar text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant