Package Exports
- mdast-util-heading-range
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-range) 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-range

Markdown heading as ranges in mdast.
Installation
npm:
npm install mdast-util-heading-rangemdast-util-heading-range is also available for duo, and as an AMD, CommonJS, and globals module, uncompressed and compressed.
Usage
var heading = require('mdast-util-heading-range');
var remark = require('remark');Process a document.
var doc = remark()
.use(function () {
return function (node) {
heading(node, 'foo', function (start, nodes, end) {
return [
start,
{
'type': 'paragraph',
'children': [
{
'type': 'text',
'value': 'Qux.'
}
]
},
end
];
});
}
}).process([
'# Foo',
'',
'Bar.',
'',
'# Baz',
''
].join('\n'));Yields:
# Foo
Qux.
# BazAPI
heading(node, test, onrun)
Transform part of a document without affecting other parts, by changing a
section: a heading which passes test, until the next heading of the same
or lower depth, or the end of the document.
Parameters
node(Node) — Node to search;test(string,RegExp,function(string, Node): boolean) — Heading to look for:When
string, wrapped innew RegExp('^(' + value + ')$', 'i');Then, when
RegExp, wrapped infunction (value) {expression.test(value)}.
onrun(Array.<Node>? = function (start, nodes, end)) — Callback invoked when a range is found.
function onrun(start, nodes, end?, scope)
Parameters
start(Heading) — Start of range;nodes(Array.<Node>) — Nodes betweenstartandend;end(Heading?) — End of range, if any.scope(Object):parent(Node) — Parent of the range;start(number) — Index ofstartinparent;end(number?) — Index ofendinparent.
Returns
Array.<Node>? — Zero or more nodes to replace the range (including
start, and end) with.