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
mdast-normalize-headings
⚠️
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.
Related
- remark-normalize-headings — remark plugin wrapper.
Install
npm install mdast-normalize-headingsLicense
MIT

