fix: calculate heading after latex (closes #719)

This commit is contained in:
Jacky Zhao 2024-02-03 19:44:24 -08:00
parent 742b883256
commit 3fb3930df8
2 changed files with 3 additions and 2 deletions

View file

@ -26,6 +26,7 @@ interface TocEntry {
}
const regexMdLinks = new RegExp(/\[([^\[]+)\](\(.*\))/, "g")
const slugAnchor = new Slugger()
export const TableOfContents: QuartzTransformerPlugin<Partial<Options> | undefined> = (
userOpts,
) => {
@ -38,7 +39,7 @@ export const TableOfContents: QuartzTransformerPlugin<Partial<Options> | undefin
return async (tree: Root, file) => {
const display = file.data.frontmatter?.enableToc ?? opts.showByDefault
if (display) {
const slugAnchor = new Slugger()
slugAnchor.reset()
const toc: TocEntry[] = []
let highestDepth: number = opts.maxDepth
visit(tree, "heading", (node) => {