-
Notifications
You must be signed in to change notification settings - Fork 96
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
没太明白 MNode 是个什么样的结构 #6
Comments
解析 md 内容的时候,生成AST,应该节点里面有children的,这个里面没有 谢谢 |
MNode各个节点的节点树,是一颗链表树,pre, next可以用于找到兄弟节点,firstChild可用于找到子节点,找到firstChild第一个字子节点后,通过firstChild-> next 就可以继续找到所有子节点,也就是children了。这里通过链表去实现 而不是children数组,方便节点高效操作 |
也可以了解下treewalker ,就是用来遍历这种结构的,和真实dom结构一样 |
这个函数是啥意思啊 |
为了 换行打 tab 缩进的时候,能够对齐上一行的 tab 。而不会因为下一行先输入了一个空格再输入tab,与上一行错位 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
大神,能不能给点解答,源码里面 MNode 类型
里面有 pre, next 了,是个双链表,怎么还有个 firstChild, lastChild 类型
有点不太明白了
`export class MNode {
type: NodeType;
parent: MNode | null = null;
firstChild: MNode | null = null;
lastChild: MNode | null = null;
prev: MNode | null = null;
next: MNode | null = null;
open: boolean = true;
stringContent: string = '';
sourceStart: number;
sourceEnd: number;
blockMarkerBefore: string | undefined = ''; // 标识占位符(叶子块需要,目前只有代码块和标题需要,因为其他叶子快内部可以包含p标签)
blockMarkerAfter: string | undefined = ''; // 标识占位符(叶子块需要,目前只有代码块和标题需要,因为其他叶子快内部可以包含p标签)
marker: string = ''; // 是否是文本标记符占位节点
isShow: boolean = true; // 是否需要显示和隐藏(隐藏的话直接不创建dom节点,占位场景)
// lastLineBlank: boolean = false; // 末尾是否存在空白行,用于换行时容器切换
constructor (sourceStart: number) {
this.sourceStart = sourceStart;
}`
The text was updated successfully, but these errors were encountered: