How to use mdast-util-assert - 4 common examples

To help you get started, we’ve selected a few mdast-util-assert examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aliyun / alibabacloud-console-components / packages / gatsby-theme-console-doc / src / buildtime / remarkPlugins / linkInstructions / remarkPlugin.ts View on Github external
}
    })

    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)
      }
    })
  }
github aliyun / alibabacloud-console-components / packages / gatsby-theme-console-doc / src / buildtime / remarkPlugins / linkInstructions / remarkPlugin.ts View on Github external
})

    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)
      }
    })
  }
github aliyun / alibabacloud-console-components / site / src / buildtime / fetchFusionDocFromGithub / fetchFusionDoc.ts View on Github external
export function ASTNodesToString(ASTNodes: mdast.Content[]) {
  const ast: mdast.Root = {
    type: 'root',
    children: [...ASTNodes],
  }
  assertMdAST(ast)
  return stringifyPipeline.stringify(ast)
}
github aliyun / alibabacloud-console-components / site / src / buildtime / fetchFusionDocFromGithub / fetchFusionDoc.ts View on Github external
export function parseMarkdown(str: string): mdast.Root {
  const ast = removePosition(parsePipeline.parse(str))
  assertMdAST(ast)
  return ast
}

mdast-util-assert

mdast utility to assert trees

MIT
Latest version published 10 months ago

Package Health Score

59 / 100
Full package analysis

Popular mdast-util-assert functions