microsoft / microsoft/language-server-protocol
Math support in Markdown
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 13k
- Forks
- 1k
- Avg merge
- 6d 1h
- Merged PRs (30d)
- 10
Description
Background
-
GitHub, which is owned by Microsoft, recently added support for using
$and$$to delimit math expressions in Markdown rendered on GitHub:Today we are pleased to announce that math expressions can be rendered in Markdown on GitHub using
$$as a delimiter for code blocks with math content or the$delimiter for inline math expressions. -
GitHub states that the Markdown syntax that GitHub supports is called GitHub Flavored Markdown (GFM):
GitHub Flavored Markdown, often shortened as GFM, is the dialect of Markdown that is currently supported for user content on GitHub.com and GitHub Enterprise.
-
The LSP spec states that the Markdown syntax supported in
MarkupContentis that very same GitHub Flavored Markdown:If the format is markdown the content should follow the GitHub Flavored Markdown Specification.
Expected behavior
Given the above, I expected to be able to use $ and $$ to render math in Markdown using LSP.
Actual behavior
However, when testing with VS Code, it doesn't work.
Notably, VS Code, also owned by Microsoft, also supports $ and $$ for math in Markdown, but apparently only in its Markdown doc preview feature.
Explanation
Digging deeper, it appears as though even though GitHub claims that GFM is the definition for Markdown on GitHub, the GFM spec hasn't been updated for a while, and doesn't mention the math rendering support. So, technically, LSP is correctly following the current GFM spec by not rendering math with dollar signs.
However, I'd like to start a discussion about whether this would be a desirable feature for LSP's Markdown. I think it'd be useful, as an example, if one could display things like big-O notation for documentation comments with proper math rendering.
Action to take
I see a few things we could do.
Update the GFM spec to talk about dollar sign math
This seems to be the most "correct" option, since GFM is supposed to be the definition of the Markdown supported by GitHub, yet there is currently a deviation between what the GFM spec states and what GitHub actually supports.
If we do this, then dollar sign math support would then enter LSP as well, since LSP states that the Markdown supported by LSP is GFM.
However, doing this would require convincing GitHub to update the GFM spec, which is not necessarily under the control of the LSP spec maintainers. (Though, as noted, both GitHub and LSP are owned by Microsoft.)
Support dollar sign math "on top" of GFM
This is what GitHub itself seems to be doing. We might choose to introduce a new flavor of MarkupContent called "GFM + dollar sign math Markdown" or something for backwards compatibility.
Do nothing
Keep the status quo, and don't support dollar sign math. But as noted, I at least would like support for this feature.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the LSP 3.17 specification's MarkupContent section and the linked GitHub math-support and GFM references. Determine whether maintainers want to update the GFM dependency, define an additional Markdown flavor, or retain current behavior; done means a decided compatibility direction and a corresponding specification change, if accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- markdown
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100