Package Exports
- mdast-util-heading-style
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-util-heading-style) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
mdast-util-heading-style
mdast utility to get the style of a heading.
Install
This package is ESM only:
Node 12+ is needed to use it and it must be imported instead of required.
npm:
npm install mdast-util-heading-styleUse
import unified from 'unified'
import remarkParse from 'remark-parse'
import {headingStyle} from 'mdast-util-heading-style'
var processor = unified().use(remarkParse)
headingStyle(processor.parse('# ATX').children[0]) // => 'atx'
headingStyle(processor.parse('# ATX #\n').children[0]) // => 'atx-closed'
headingStyle(processor.parse('ATX\n===').children[0]) // => 'setext'
headingStyle(processor.parse('### ATX').children[0]) // => null
headingStyle(processor.parse('### ATX').children[0], 'setext') // => 'setext'API
This package exports the following identifiers: headingStyle.
There is no default export.
headingStyle(node[, relative])
Get the heading style of a node.
Parameters
node(Node) — Node to parserelative(string, optional) — Style to use for ambiguous headings (atx-headings with a level of three or more could also be setext)
Returns
string ('atx', 'atx-closed', or 'setext') — When an ambiguous
heading is found, either relative or null is returned.
Security
Use of mdast-util-heading-style does not involve hast so there are
no openings for cross-site scripting (XSS) attacks.
Related
mdast-normalize-headings— make sure there is no more than a single top-level headingmdast-util-heading-range— use headings as ranges
Contribute
See contributing.md in syntax-tree/.github for ways to get
started.
See support.md for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.