-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Implement Latex math formulas in docgen #22657
Comments
The problem with LaTeX's syntax is that even though math formulas are in a hidden tree structure (AST) LaTeX's representation is not an AST. It's unnecessarily losing information and is overly concerned with rendering aspects, quite ironically. |
Allows to type LaTeX math formulas using RST syntax like this: ## Solves the quadratic equation :math:`ax^2+bx+c = 0` using the formula: ## ## .. math:: x = -b ± \frac{\sqrt{b^2 - 4ac}}{2a}
The explicit hierarchical representation is great only for specific purposes like efficient parsing or programmatical tree modification. For text editing of formulas it just should be concise and hence readable, and Latex is good at it. |
There is nothing particularly readable about Latex's syntax and I don't even want to know how many bugs it caused in published papers. The math community is happier with Mathematica which keeps the tree structure. |
How to write |
There is no ready to use renderer for Mathematica formulas. Your comments are valid but they don't propose a meaningful strategy. The situation is similar to the choice of Markdown as default language. W.r.t. e.g. HTML both RST and Markdown do not manifest explicit tree structure in many parts, but Markdown is even worse:
But there are no well-established alternatives to Markdown, so it's OK to adopt some of these things that have some use or are familiar to use. Nim project is not required to solve all the problems of programming world. Alternatives may become ready only in long time like 20 years, then only then there will be the time to switch to them. |
Whatever syntax we implement should map easily to MathML. It can be a clean subset of LaTeX or it can be the full thing if there is a reasonably complete list of its quirks somewhere. |
Summary
We don't have a feature to type mathematical formulas in our markup language.
RST, Github Markdown, Pandoc Markdown all support the display of Latex formulas.
Description
For Markdown mode we can adopt the syntax shared by Github extension and Pandoc extension.
Inline$\sqrt{3x-1}+(1+x)^2$
$$\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)$$
Block:
Need to implement syntax in parser (rst.nim) and output generation (rstgen.nim).
For HTML rendering I suggest to make implementation based on Katex as the easiest option (MathML is incomparably more difficult).
Alternatives
No response
Examples
No response
Backwards Compatibility
No response
Links
No response
The text was updated successfully, but these errors were encountered: