Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
})
let passCount = 0
do {
if (++passCount > MAX_PASS_COUNT) {
throw new Error(`AST transformation takes too many passes!
The transformation should be stable in ${MAX_PASS_COUNT} passes.
Maybe some plugins is returning something **unconditionally**.
Plugin should only return something(the tree) if they actually transform the tree.`)
}
// loop until we can't find any link instruction (which means stable)
const found = await fineOneInstructionAndExectue(tree, file)
// validate tree structure
assertMdAST(tree)
assertMdAST.parent(tree)
if (!found) break // ast reach stable
} while (true)
instructions.forEach(({ afterVisitTree }) => {
if (typeof afterVisitTree === 'function') {
afterVisitTree(tree, file)
}
})
}
})
let passCount = 0
do {
if (++passCount > MAX_PASS_COUNT) {
throw new Error(`AST transformation takes too many passes!
The transformation should be stable in ${MAX_PASS_COUNT} passes.
Maybe some plugins is returning something **unconditionally**.
Plugin should only return something(the tree) if they actually transform the tree.`)
}
// loop until we can't find any link instruction (which means stable)
const found = await fineOneInstructionAndExectue(tree, file)
// validate tree structure
assertMdAST(tree)
assertMdAST.parent(tree)
if (!found) break // ast reach stable
} while (true)
instructions.forEach(({ afterVisitTree }) => {
if (typeof afterVisitTree === 'function') {
afterVisitTree(tree, file)
}
})
}
export function ASTNodesToString(ASTNodes: mdast.Content[]) {
const ast: mdast.Root = {
type: 'root',
children: [...ASTNodes],
}
assertMdAST(ast)
return stringifyPipeline.stringify(ast)
}
export function parseMarkdown(str: string): mdast.Root {
const ast = removePosition(parsePipeline.parse(str))
assertMdAST(ast)
return ast
}