How to use mdast-util-definitions - 2 common examples

To help you get started, we’ve selected a few mdast-util-definitions 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 netlify / netlify-cms / src / components / Widgets / Markdown / unified.js View on Github external
const transform = (node, index, siblings, parent) => {
    let nodes;

    if (node.type === 'root') {
      // Create definition getter for link and image references
      getDefinition = mdastDefinitions(node);
      // Ensure top level text nodes are wrapped in paragraphs
      modifyChildren(wrapText)(node);
    }

    if (isEmpty(node.children)) {
      nodes = node.children;
    } else {
      // If a node returns a falsey value, exclude it. Some nodes do not
      // translate from MDAST to Slate, such as definitions for link/image
      // references or footnotes.
      //
      // Consider using unist-util-remove instead for this.
      nodes = node.children.reduce((acc, childNode, idx, sibs) => {
        const transformed = transform(childNode, idx, sibs, node);
        if (transformed) {
          acc.push(transformed);
github netlify / netlify-cms / packages / netlify-cms-widget-markdown / src / serializers / remarkSquashReferences.js View on Github external
function getTransform(node) {
    const getDefinition = mdastDefinitions(node);
    return transform.call(null, getDefinition, node);
  }

mdast-util-definitions

mdast utility to find definition nodes in a tree

MIT
Latest version published 10 months ago

Package Health Score

74 / 100
Full package analysis

Popular mdast-util-definitions functions