Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mdast-util-heading-range

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdast-util-heading-range - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

41

history.md

@@ -1,9 +0,18 @@

<!--mdast setext-->
<!--remark setext-->
<!--lint disable no-multiple-toplevel-headings-->
2.0.0 / 2016-01-17
==================
* Update API to remove remark dependency ([`3edfeee`](https://github.com/wooorm/mdast-util-heading-range/commit/3edfeee))
* Remove support for bower ([`36a4733`](https://github.com/wooorm/mdast-util-heading-range/commit/36a4733))
* Refactor npm test target ([`c5bc9ae`](https://github.com/wooorm/mdast-util-heading-range/commit/c5bc9ae))
* Refactor to replace mocha with tape ([`4cf70ce`](https://github.com/wooorm/mdast-util-heading-range/commit/4cf70ce))
* Update `mdast` to `remark` ([`6df612d`](https://github.com/wooorm/mdast-util-heading-range/commit/6df612d))
1.0.2 / 2015-08-23
==================
* Fix bug where nodes were passed incorrectly ([4b036e4](https://github.com/wooorm/mdast-util-heading-range/commit/4b036e4))
* Fix bug where nodes were passed incorrectly ([`4b036e4`](https://github.com/wooorm/mdast-util-heading-range/commit/4b036e4))

@@ -13,3 +22,3 @@ 1.0.1 / 2015-08-19

* Fix bug ([689f250](https://github.com/wooorm/mdast-util-heading-range/commit/689f250))
* Fix bug ([`689f250`](https://github.com/wooorm/mdast-util-heading-range/commit/689f250))

@@ -19,4 +28,4 @@ 1.0.0 / 2015-08-18

* Refactor to make installation section smaller ([b5699e5](https://github.com/wooorm/mdast-util-heading-range/commit/b5699e5))
* Update dependencies, dev-dependencies ([25f00b9](https://github.com/wooorm/mdast-util-heading-range/commit/25f00b9))
* Refactor to make installation section smaller ([`b5699e5`](https://github.com/wooorm/mdast-util-heading-range/commit/b5699e5))
* Update dependencies, dev-dependencies ([`25f00b9`](https://github.com/wooorm/mdast-util-heading-range/commit/25f00b9))

@@ -26,3 +35,3 @@ 0.1.3 / 2015-07-12

* Remove peer-dependencies ([47589b6](https://github.com/wooorm/mdast-util-heading-range/commit/47589b6))
* Remove peer-dependencies ([`47589b6`](https://github.com/wooorm/mdast-util-heading-range/commit/47589b6))

@@ -32,8 +41,8 @@ 0.1.2 / 2015-06-14

* Remove `.npmignore` in favour of `files` in `package.json` ([abfc010](https://github.com/wooorm/mdast-util-heading-range/commit/abfc010))
* Add mdast-lint as a dev-dependency ([8520a6c](https://github.com/wooorm/mdast-util-heading-range/commit/8520a6c))
* Refactor lint targets ([f1bf4b9](https://github.com/wooorm/mdast-util-heading-range/commit/f1bf4b9))
* Add `.editorconfig` ([6765f89](https://github.com/wooorm/mdast-util-heading-range/commit/6765f89))
* Update mdast ([e0b6e90](https://github.com/wooorm/mdast-util-heading-range/commit/e0b6e90))
* Update browserify, eslint, jscs-jsdoc ([be1259e](https://github.com/wooorm/mdast-util-heading-range/commit/be1259e))
* Remove `.npmignore` in favour of `files` in `package.json` ([`abfc010`](https://github.com/wooorm/mdast-util-heading-range/commit/abfc010))
* Add mdast-lint as a dev-dependency ([`8520a6c`](https://github.com/wooorm/mdast-util-heading-range/commit/8520a6c))
* Refactor lint targets ([`f1bf4b9`](https://github.com/wooorm/mdast-util-heading-range/commit/f1bf4b9))
* Add `.editorconfig` ([`6765f89`](https://github.com/wooorm/mdast-util-heading-range/commit/6765f89))
* Update mdast ([`e0b6e90`](https://github.com/wooorm/mdast-util-heading-range/commit/e0b6e90))
* Update browserify, eslint, jscs-jsdoc ([`be1259e`](https://github.com/wooorm/mdast-util-heading-range/commit/be1259e))

@@ -43,8 +52,8 @@ 0.1.1 / 2015-04-15

* Update eslint ([63ae427](https://github.com/wooorm/mdast-util-heading-range/commit/63ae427))
* Update mdast ([09dc2a3](https://github.com/wooorm/mdast-util-heading-range/commit/09dc2a3))
* Add mdast-toc as a dependency ([49d1bf3](https://github.com/wooorm/mdast-util-heading-range/commit/49d1bf3))
* Rebuild ([7a7ae6e](https://github.com/wooorm/mdast-util-heading-range/commit/7a7ae6e))
* Update eslint ([`63ae427`](https://github.com/wooorm/mdast-util-heading-range/commit/63ae427))
* Update mdast ([`09dc2a3`](https://github.com/wooorm/mdast-util-heading-range/commit/09dc2a3))
* Add mdast-toc as a dependency ([`49d1bf3`](https://github.com/wooorm/mdast-util-heading-range/commit/49d1bf3))
* Rebuild ([`7a7ae6e`](https://github.com/wooorm/mdast-util-heading-range/commit/7a7ae6e))
0.1.0 / 2015-04-15
==================

@@ -0,3 +1,13 @@

/**
* @author Titus Wormer
* @copyright 2015 Titus Wormer
* @license MIT
* @module mdast:util:heading-range
* @fileoverview Markdown heading as ranges in mdast.
*/
'use strict';
/* eslint-env commonjs */
/*

@@ -19,3 +29,3 @@ * Dependencies.

* @param {string} value - Value to transform.
* @return {RegExp}
* @return {RegExp} - Expression.
*/

@@ -30,3 +40,3 @@ function toExpression(value) {

* @param {RegExp} expression - Expression to test.
* @return {Function}
* @return {Function} - Assertion.
*/

@@ -38,3 +48,3 @@ function wrapExpression(expression) {

* @param {string} value - Value to check.
* @return {boolean}
* @return {boolean} - Whether `value` matches.
*/

@@ -52,3 +62,3 @@ function assertion(value) {

* @param {Node} node - Node to check.
* @return {boolean}
* @return {boolean} - Whether `node` is a heading.
*/

@@ -65,4 +75,4 @@ function isHeading(node) {

* @param {function(string): boolean} test - Tester.
*
* @return {boolean}
* @return {boolean} - Whether `node` is an opening
* heading.
*/

@@ -78,3 +88,4 @@ function isOpeningHeading(node, depth, test) {

* @param {number?} depth - Depth of the opening heading.
* @return {boolean}
* @return {boolean} - Whether `node` is a closing
* heading.
*/

@@ -157,4 +168,5 @@ function isClosingHeading(node, depth) {

/**
* Wrapper.
* Search `node` for `heading` and invoke `callback`.
*
* @param {Node} node - Node to search in.
* @param {string|RegExp|Function} heading - Heading to

@@ -164,5 +176,4 @@ * search for.

* found.
* @return {function(node)}
*/
function wrapper(heading, callback) {
function headingRange(node, heading, callback) {
var test = heading;

@@ -178,21 +189,3 @@

/**
* Find a range based on a starting heading matching
* `test`, up until the following closing with
* equal or higher depth.
*
* @param {Node} node - Node to search in.
*/
function transformer(node) {
search(node, test, callback);
}
/**
* `Attacher`.
*/
function attacher() {
return transformer;
}
return attacher;
search(node, test, callback);
}

@@ -204,2 +197,2 @@

module.exports = wrapper;
module.exports = headingRange;
{
"name": "mdast-util-heading-range",
"version": "1.0.2",
"version": "2.0.0",
"description": "Markdown heading as ranges in mdast",

@@ -21,31 +21,29 @@ "license": "MIT",

"devDependencies": {
"browserify": "^11.0.0",
"browserify": "^13.0.0",
"eslint": "^1.0.0",
"esmangle": "^1.0.0",
"istanbul": "^0.3.0",
"istanbul": "^0.4.0",
"jscs": "^2.0.0",
"jscs-jsdoc": "^1.0.0",
"mdast": "^1.0.0",
"mdast-comment-config": "^1.0.0",
"mdast-github": "^0.3.0",
"mdast-lint": "^1.0.0",
"mdast-toc": "^0.5.0",
"mdast-usage": "^0.3.0",
"mdast-validate-links": "^0.3.0",
"mocha": "^2.0.0"
"remark": "^3.0.0",
"remark-comment-config": "^2.0.0",
"remark-github": "^3.0.0",
"remark-lint": "^2.0.0",
"remark-toc": "^2.0.0",
"remark-usage": "^2.0.0",
"remark-validate-links": "^2.0.0",
"tape": "^4.4.0"
},
"scripts": {
"test-api": "mocha --check-leaks test.js",
"test-coverage": "istanbul cover _mocha -- test.js",
"test-travis": "npm run test-coverage",
"test": "npm run test-api",
"build-md": "remark . --quiet --frail",
"build-bundle": "browserify index.js --no-builtins -s mdastUtilHeadingRange > mdast-util-heading-range.js",
"build-mangle": "esmangle mdast-util-heading-range.js > mdast-util-heading-range.min.js",
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
"lint-api": "eslint .",
"lint-style": "jscs --reporter inline .",
"lint": "npm run lint-api && npm run lint-style",
"make": "npm run lint && npm run test-coverage",
"bundle": "browserify index.js --no-builtins -s mdastUtilHeadingRange > mdast-util-heading-range.js",
"postbundle": "esmangle mdast-util-heading-range.js > mdast-util-heading-range.min.js",
"build-md": "mdast . --output --quiet",
"build": "npm run bundle && npm run build-md"
"test-api": "node test.js",
"test-coverage": "istanbul cover test.js",
"test": "npm run build && npm run lint && npm run test-coverage"
}
}

@@ -1,8 +0,8 @@

# mdast-util-heading-range [![Build Status](https://img.shields.io/travis/wooorm/mdast-util-heading-range.svg)](https://travis-ci.org/wooorm/mdast-util-heading-range) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/mdast-util-heading-range.svg)](https://codecov.io/github/wooorm/mdast-util-heading-range)
# mdast-util-heading-range [![Build Status][travis-badge]][travis] [![Coverage Status][coverage-badge]][coverage]
Markdown heading as ranges in [**mdast**](https://github.com/wooorm/mdast).
Markdown heading as ranges in [**mdast**][mdast].
## Installation
[npm](https://docs.npmjs.com/cli/install):
[npm][npm-install]:

@@ -13,19 +13,6 @@ ```bash

**mdast-util-heading-range** is also available for [bower](http://bower.io/#install-packages),
[component](https://github.com/componentjs/component), and
[duo](http://duojs.org/#getting-started), and as an AMD, CommonJS, and globals
module, [uncompressed](mdast-util-heading-range.js) and [compressed](mdast-util-heading-range.min.js).
**mdast-util-heading-range** is also available for [duo][],
and as an AMD, CommonJS, and globals module,
[uncompressed and compressed][releases].
## Table of Contents
* [Usage](#usage)
* [API](#api)
* [heading(test, onrun)](#headingtest-onrun)
* [function onrun(start, nodes, end?, scope)](#function-onrunstart-nodes-end-scope)
* [License](#license)
## Usage

@@ -35,35 +22,35 @@

var heading = require('mdast-util-heading-range');
var mdast = require('mdast');
var remark = require('remark');
```
Callback invoked when a heading is found.
```javascript
function onrun(start, nodes, end) {
return [
start,
{
'type': 'paragraph',
'children': [
{
'type': 'text',
'value': 'Qux.'
}
]
},
end
];
}
```
Process a document.
```javascript
var doc = mdast().use(heading('foo', onrun)).process(
'# Foo\n' +
'\n' +
'Bar.\n' +
'\n' +
'# Baz\n'
);
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'));
```

@@ -83,3 +70,3 @@

### heading(test, onrun)
### `heading(node, test, onrun)`

@@ -92,2 +79,4 @@ Transform part of a document without affecting other parts, by changing a

* `node` ([`Node`][mdast-node]) — Node to search;
* `test` (`string`, `RegExp`, `function(string, Node): boolean`)

@@ -106,8 +95,4 @@ — Heading to look for:

**Returns**
#### `function onrun(start, nodes, end?, scope)`
`Function` — Should be passed to [`mdast.use()`](https://github.com/wooorm/mdast#mdastuseplugin-options).
#### function onrun(start, nodes, end?, scope)
**Parameters**

@@ -134,2 +119,26 @@

[MIT](LICENSE) © [Titus Wormer](http://wooorm.com)
[MIT][license] © [Titus Wormer][home]
<!-- Definitions -->
[travis-badge]: https://img.shields.io/travis/wooorm/mdast-util-heading-range.svg
[travis]: https://travis-ci.org/wooorm/mdast-util-heading-range
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/mdast-util-heading-range.svg
[coverage]: https://codecov.io/github/wooorm/mdast-util-heading-range
[mdast]: https://github.com/wooorm/mdast
[mdast-node]: https://github.com/wooorm/mdast#node
[npm-install]: https://docs.npmjs.com/cli/install
[duo]: http://duojs.org/#getting-started
[releases]: https://github.com/wooorm/mdast-util-heading-range/releases
[license]: LICENSE
[home]: http://wooorm.com
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc