Open randallwc opened 3 years ago
This looks to be a regression because we chose to use a markdown-it
engine to parse the document, which is principled in theory.
The problem is Math is not in the CommonMark spec.
cc @Lemmingh.
This post is essentially two issues. I probably should have separated them from the start.
First, is the math mode syntax being registered as a heading (which is a bad thing) but not displayed as one in preview (which is a good thing).
Second, is that the syntax of using a minus sign below any word should make it a heading 2
which it does in the preview but it doesn't add it to the TOC.
I feel like the first issue might be a regression but I think the second issue is about TOC. But I am primarily focused on the first issue because this weird syntax of -
and =
is kinda not useful in markdown but others might use it.
Second, is that the syntax of using a minus sign below any word should make it a
heading 2
which it does in the preview but it doesn't add it to the TOC.
I'm using the latest dev build and it works "as expected"
A very old problem, for years.
For now, we can move all TOC operations onto mdEngine
.
A final fix won't land until we finish our language service.
For TOC operations in our product, we are mimicking the default configuration of VS Code's markdown-language-features
: Load markdown-it-front-matter
.
So other syntax, including math, is not considered.
As mentioned above, the fix could be loading markdown-it-front-matter
in mdEngine
, which already loads other markdown-it
plugins, in the same way:
Then adapt getAllTocEntry()
.
In short, there are a few mismatches between components.
In the long term, I think we will solve this (a certain level of compatibility is needed). But there is no easy fix given the current state. In contrast, we can simply avoid this issue if we don't write equations like that.
Yeah. Just had a deeper look. Even a short term fix could take months.
Not only is the change big, but also the wait chain is long.
Major work items:
completion
to a new model. (#905)toc
.toc
to a completely async model.mdEngine
. (this)Such a long list is just caused by the asynchronous nature of mdEngine
. 😂
Problem
'=' causes line above to be a header in TOC when in math mode '-' doesn't show up in TOC when used as a secondary header syntax
How to reproduce
https://www.markdownguide.org/basic-syntax/
here is the TOC created from a simple equation
what it should be is
Error message in the console