Skip to content

[feature request]: Support rendering LaTeX math expressions in documentation comments #4277

Open

Description

@dzylikecode

It would be useful if Dart documentation comments could render mathematical expressions written in LaTeX syntax.

Dart documentation comments already support Markdown, but currently there is no built-in way to render mathematical formulas in generated API documentation.

For example, it would be nice to write:

/// Computes the loss function:
///
/// $$
/// L(\theta) = \frac{1}{N}\sum_{i=1}^{N}
/// (f_\theta(x_i) - y_i)^2
/// $$
///
/// The gradient is $\nabla_\theta L(\theta)$.
double loss(...) {
  ...
}

and have dart doc render both the block and inline equations as formatted mathematics.

Activity

  1. srawlins commented on Aug 12, 2026

    @srawlins
    Member

    GitHub supports a syntax that uses MathJax I believe. https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/writing-mathematical-expressions

    This sentence uses $` and `$ delimiters to show math inline: $\sqrt{3x-1}+(1+x)^2$

    So if it were well-specified in GFM (which I do not think it is), we could add it easily. Otherwise it is sort of a product decision whether we depart from GFM, but align with what users will see on GitHub in their READMEs and other Markdown files.

  2. sigurdm commented on Aug 13, 2026

    @sigurdm
    Contributor

    I agree with aligning with github whatever they do

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions