Skip to content

syntax-tree/mdast-util-heading-style

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

mdast-util-heading-style Build Status Coverage Status Chat

Get the style of an MDAST heading.

Installation

npm:

npm install mdast-util-heading-style

Usage

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

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

style(remark.parse('### ATX').children[0]); // null
style(remark.parse('### ATX').children[0], 'setext'); // 'setext'

API

style(node[, relative])

Get the heading style of a node.

Parameters
  • node (Node) — Node to parse
  • relative (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.

License

MIT © Titus Wormer

About

utility to get the style of an mdast heading

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •