unified

Project:syntax-tree/mdast-util-heading-style

Package:mdast-util-heading-style@1.0.6

  1. Dependencies:0·Dependents:2
  2. mdast utility to get the style of a heading
  1. markdown 82
  2. unist 80
  3. util 78
  4. utility 78
  5. mdast 68
  6. heading 24
  7. node 21
  8. mdast-util 14
  9. style 10

mdast-util-heading-style

Build Coverage Downloads Size Sponsors Backers Chat

mdast utility to get the style of a heading.

Install

npm:

npm install mdast-util-heading-style

Use

var style = require('mdast-util-heading-style')
var unified = require('unified')
var parse = require('remark-parse')

var processor = unified().use(parse)

style(processor.parse('# ATX').children[0]) // => 'atx'
style(processor.parse('# ATX #\n').children[0]) // => 'atx-closed'
style(processor.parse('ATX\n===').children[0]) // => 'setext'

style(processor.parse('### ATX').children[0]) // => null
style(processor.parse('### ATX').children[0], 'setext') // => 'setext'

API

style(node[, relative])

Get the heading style of a node.

Parameters
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.

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.

License

MIT © Titus Wormer