Get the style of an MDAST heading.
npm:
npm install mdast-util-heading-style
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'
Get the heading style of a node.
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)
string
('atx'
, 'atx-closed'
, or 'setext'
) — When an ambiguous
heading is found, either relative
or null
is returned.