Skip to content

Conversation

@alexiscolin
Copy link
Member

feat: Add MathML extension for gnoweb markdown

This PR adds a comprehensive MathML extension (ext_math) to gnoweb's markdown rendering system, enabling full server-side LaTeX support with MathML output (native browser ext: no need for a front-end plugin or image generation).

Features

Mathematical Expression Support

  • Inline math: $E = mc^2$ → Rendered as MathML
  • Display math: $$ \int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi} $$ → Rendered as MathML
  • LaTeX delimiters: \(...\) and \[...\] support

Comprehensive LaTeX Support

  • Greek letters: \alpha, \beta, \gamma, \Delta, \Omega, etc.
  • Mathematical operators: \times, \div, \pm, \leq, \geq, \neq, \approx
  • Functions: \sin, \cos, \tan, \log, \ln, \exp, \max, \min
  • Integrals and sums: \int, \sum, \prod, \lim
  • Set theory: \in, \notin, \subset, \supset, \cup, \cap, \emptyset
  • Logical operators: \land, \lor, \lnot, \forall, \exists
  • Arrows: \rightarrow, \leftarrow, \Rightarrow, \Leftarrow
  • Matrices: \begin{matrix}...\end{matrix}, \begin{pmatrix}...\end{pmatrix}
  • Fractions: \frac{numerator}{denominator}
  • Superscripts/Subscripts: x^2, x_1, x^{2+3}, x_{i+1}
  • Roots: \sqrt{x}, \sqrt[n]{x}

Implementation Details

Parser Integration

  • Extends gnoweb's markdown parser with custom AST nodes (MathInline, MathBlock)
  • Supports multiple delimiter patterns: $...$, $$...$$, \(...\), \[...\]
  • Integrates seamlessly with existing markdown processing pipeline

MathML Generation

  • Converts LaTeX expressions to valid MathML markup
  • Handles complex mathematical structures (matrices, fractions, integrals)
  • Supports both inline and display math contexts
  • Generates semantic MathML for accessibility

Screenshot

Capture d’écran 2025-09-11 à 18 48 24 488653292-ef222ded-b247-4c9c-976d-49f6ade5a446 488653278-cc0a7eb9-0a33-40d9-ac67-b3bc747b9158 488651368-035a8f87-ffb1-41c5-a81d-14802283580f

PS: This library is based on TreeBlood (originally by Wyatt915) and has been updated and fixed for our gnoweb needs.

@github-actions github-actions bot added 🧾 package/realm Tag used for new Realms or Packages. 📦 ⛰️ gno.land Issues or PRs gno.land package related 🌍 gnoweb Issues & PRs related to gnoweb and render labels Nov 9, 2025
@Gno2D2 Gno2D2 requested a review from gfanton November 9, 2025 14:24
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Nov 9, 2025

🛠 PR Checks Summary

🔴 Changes related to gnoweb must be reviewed by its codeowners

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)
🔴 Changes related to gnoweb must be reviewed by its codeowners

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: alexiscolin/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Changes related to gnoweb must be reviewed by its codeowners

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 A changed file matches this pattern: ^gno.land/pkg/gnoweb/ (filename: gno.land/pkg/gnoweb/frontend/css/05-composition.css)

Then

🔴 Requirement not satisfied
└── 🔴 Or
    ├── 🔴 Or
    │   ├── 🔴 And
    │   │   ├── 🟢 Pull request author is user: alexiscolin
    │   │   └── 🔴 This user reviewed pull request: gfanton (with state "APPROVED")
    │   └── 🔴 And
    │       ├── 🔴 Pull request author is user: gfanton
    │       └── 🔴 This user reviewed pull request: alexiscolin (with state "APPROVED")
    └── 🔴 And
        ├── 🔴 Not (🟢 Pull request author is user: alexiscolin)
        ├── 🟢 Not (🔴 Pull request author is user: gfanton)
        └── 🔴 Or
            ├── 🔴 This user reviewed pull request: alexiscolin (with state "APPROVED")
            └── 🔴 This user reviewed pull request: gfanton (with state "APPROVED")

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌍 gnoweb Issues & PRs related to gnoweb and render 📦 ⛰️ gno.land Issues or PRs gno.land package related 🧾 package/realm Tag used for new Realms or Packages.

Projects

Status: No status
Status: Triage

Development

Successfully merging this pull request may close these issues.

2 participants