Skip to content

feat: Add math rendering support to markdown #3709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

IAdityaKaushal
Copy link

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

This PR adds support for rendering LaTeX-style mathematical expressions in markdown output. This addresses issue #3159 which requested the ability to display mathematical equations in terminal markdown.

Features Added:

  • New MathRenderer class that converts LaTeX math syntax to Unicode representation
  • Integration of math rendering into the existing markdown processing pipeline
  • Support for both inline math ($...$) and block math ($$...$$) expressions
  • Comprehensive test suite for math rendering functionality

Implementation Details:

  • The renderer supports common LaTeX symbols including Greek letters, operators, superscripts, and subscripts
  • Preserves spacing in simple equations for better readability
  • Gracefully falls back to plaintext when symbols cannot be rendered

This enhancement significantly expands Rich's capabilities for scientific and educational applications, allowing users to render mathematical expressions directly in the terminal.

Fixes/supports feature request #3159 linked here
#3159

- Add MathRenderer class for converting Latex math to Unicode
- Integrate math rendering into markdown processing
- Supports inline ($..$) and block (94329...94329) math expressions
- Add tests for math rendering functionality

Addreses Textualize#3159
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