-
Notifications
You must be signed in to change notification settings - Fork 35
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
feat: Generate table of contents code action #17
Conversation
@keynmol what do you think about generating toc with a heading |
One issue with this is that currently Marksman's parser detects YAML frontmatter stuff like:
As a heading, and adds it to the TOC. I believe this is parser's deficiency, as it interprets the yaml block (which arguably isn't a part of the markdown spec) as one of the syntaxes for headings: What makes matters worse is that Markdown is hardOnly heuristic is really that the first line of the file is |
@keynmol I think UPDATE: we can do it in a separate PR if you want. I'd rather merge this one and improve separately, so that GH stop considering you a "First time contributor" and making me approve running CI on your PRs 😄 |
Ok, game plan:
|
Very basic demonstration of how a "Create TOC" can be implemented.
Note that I don't know F# at all :D
TODO:
Learn F#
Detect an existing TOC and update it when the code action is invoked (can even put diagnostics on the exact locations saying it's out of date)This is actually non-trivial if done in a non-invasive manner - only heuristic that can possibly exist is "first block of nothing but links in the document" and it can be easily broken. Can also match those links to a set of headings for some overlap number.