JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13740
  • Score
    100M100P100Q153010F
  • License MIT

Make sure there is no more than a single top-level heading in the document

Package Exports

  • mdast-normalize-headings

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mdast-normalize-headings) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm

mdast-normalize-headings

Build Status Dependency Status

⚠️

This is an AST transformer for mdast syntax trees. A remark plugin has been split off into a different project.

Providing multiple top-level headings per single Markdown document is confusing for tools that assume that there is only a single top-level heading that contains some meta-information (usually title) about the document.

This mdast transformer makes sure that there is only one top-level heading in the document by adjusting headings depths accordingly.

Originally extracted from remark-man.

Example

var normalizeHeadings = require('mdast-normalize-headings');

ast
//=> {
//     "type": "root",
//     "children": [
//       {
//         "type": "heading",
//         "depth": 1,
//         "children": [
//           {
//             "type": "text",
//             "value": "title"
//           }
//         ]
//       },
//       {
//         "type": "heading",
//         "depth": 2,
//         "children": [
//           {
//             "type": "text",
//             "value": "description"
//           }
//         ]
//       },
//       {
//         "type": "heading",
//         "depth": 1,
//         "children": [
//           {
//             "type": "text",
//             "value": "example"
//           }
//         ]
//       }
//     ]
//   }

normalizeHeadings(ast)
//=> {
//     "type": "root",
//     "children": [
//       {
//         "type": "heading",
//         "depth": 1,
//         "children": [
//           {
//             "type": "text",
//             "value": "title"
//           }
//         ]
//       },
//       {
//         "type": "heading",
//         "depth": 3,
//         "children": [
//           {
//             "type": "text",
//             "value": "description"
//           }
//         ]
//       },
//       {
//         "type": "heading",
//         "depth": 2,
//         "children": [
//           {
//             "type": "text",
//             "value": "example"
//           }
//         ]
//       }
//     ]
//   }

API

normalizeHeadings(ast)

Modifies AST in-place. Returns ast.

Install

npm install mdast-normalize-headings

License

MIT