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

To help you get started, we’ve selected a few mdast-util-toc 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 IBM / nicedoc.io / core / build / toc.js View on Github external
function generateTocFromContent (node) {
  return mdastToc(node, {
    maxDepth: 6,
    tight: true,
    prefix: 'user-content-'
  })
}
github SonarSource / sonarqube / server / sonar-web / src / main / js / components / docs / plugins / remark-toc.js View on Github external
function transformer(node) {
    const result = util(node, { heading, maxDepth: depth, tight });

    if (result.index === null || result.index === -1 || !result.map) {
      return;
    }

    node.children = [].concat(
      node.children.slice(0, result.index),
      result.map,
      node.children.slice(result.index)
    );
  }
}
github SonarSource / sonarqube / server / sonar-web / src / main / js / components / docs / plugins / remark-only-toc.js View on Github external
function transformer(node) {
    const result = util(node, { heading: 'doctoc', maxDepth: 2 });

    if (result.index === null || result.index === -1 || !result.map) {
      node.children = [];
    } else {
      node.children = [result.map];
    }
  }
}
github listcommunity / support / src / markdownUtils.js View on Github external
function transformer(node) {
    const result = utiltoc(node, {
      maxDepth: 4,
      tight: false,
      ...options,
    });

    node.children = result.map ? [result.map] : [];
  }
};

mdast-util-toc

mdast utility to generate a table of contents from a tree

MIT
Latest version published 5 months ago

Package Health Score

76 / 100
Full package analysis

Popular mdast-util-toc functions