-
Notifications
You must be signed in to change notification settings - Fork 331
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
🐛 Rewrite heading processing #877
Conversation
Next: Correct callers. Estimate: 4 steps.
Do not mix definitions of different structures!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in progess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the great effort! ❤
One last question: should we force all the users to adopt the [heading](<link>)
-style TOC? It will affect hundreds of thousands of people (creating a change to their git history). I would suggest not adding this when/where it is not necessary.
But we never care about those non-root headings, right 😳? It is true that they are "headings" tags in terms of the syntax tree, but we won't say they are "headings" in terms of a document/article. Also, it looks like we didn't make use of the syntax tree at all in this function. So I guess it would be better to move this "root" thing from the name to a piece of comment. |
It's just our current architecture cannot handle them. (the same reason as stated above) We indeed have to consider them! They play an important role in generating slugs. And implementations differ. To solve all the problems, I'm privately prototyping version 4, where almost all features are powered by two language servers (one for symbol info and theming, the other for actions), and a plugin system is first class member. I now get stuck constructing AST from markdown-it Tokens. |
Probably I don't have enough context (about your plan). I was just saying it (assuming Do you mean there are other cases where a heading nested in some blocks should be considered in the current feature set? |
Not sure whether we should do it in this PR, but #880 is an example supporting this. |
I'll email you more details next month. export type ProviderResult<T> = T | Thenable<T>;
export interface IHeadingInfoProvider<T extends IHeadingInfo = IHeadingInfo> {
readonly provideHeadingInfo: (document: vscode.TextDocument, options: IHeadingInfoOption, token: vscode.CancellationToken) => ProviderResult<T[]>;
readonly resolveHeadingInfo: (items: T[], token: vscode.CancellationToken) => ProviderResult<Required<T>[]>;
}
export interface IHeadingInfoOption {
documentMode: SlugifyMode;
projectLevelOmittedHeading: [markdownSpec.MarkdownHeadingLevel, string][] | undefined;
respectMagicCommentOmit: boolean;
}
export interface IHeadingInfo {
location: vscode.Location;
level: markdownSpec.MarkdownHeadingLevel;
rawContent: string;
canInToc?: boolean;
slug?: string;
visibleText?: string;
}
Yes. They play an important role in generating slugs. And I tend to regard the existence of Render this example: # Heading A
> + # Heading B ###
# Heading B It's evident that GitHub, GitLab, VS Code, Azure DevOps ... all assign anchor ID to all headings no matter where they are. Then, you have to get all headings to calculate slugs correctly.
Probably in 2022. NOT now. I cannot make it within this month. I tried to work directly on token stream. But as you can see in |
Makes sense to me 👍
Interesting. I didn't know it before.
That is fine. BTW, my next big plan is to implement the "export as PDF" feature and that will bring us to the next major update (v4.0.0), although I am not sure when it will be done 🤣. Just take your (our) time. |
* Clean up logic related to magic comment, since you've clarified the design. * Tune comments to isolate function logic, that's, don't reveal one function's logic in the comments within another. * Revert unnecessary change in package-lock.
🍻 |
Summary
getAllRootHeading()
. (Rewrite the whole function.)IHeading
.detectTocRanges()
on top of markdown-it to eliminate various mysterious bugs.REGEX_FENCED_CODE_BLOCK
,isInFencedCodeBlock()
.slugify()
.