Socket
Socket
Sign inDemoInstall

unified

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unified - npm Package Compare versions

Comparing version 6.2.0 to 7.0.0

6

package.json
{
"name": "unified",
"version": "6.2.0",
"version": "7.0.0",
"description": "Pluggable text processing interface",

@@ -31,3 +31,3 @@ "license": "MIT",

"trough": "^1.0.0",
"vfile": "^2.0.0",
"vfile": "^3.0.0",
"x-is-string": "^0.1.0"

@@ -43,3 +43,3 @@ },

"tape": "^4.4.0",
"xo": "^0.20.0"
"xo": "^0.21.0"
},

@@ -46,0 +46,0 @@ "scripts": {

@@ -339,2 +339,35 @@ # ![unified][logo]

`parse` does not apply [transformers from the run phase][description] to the
[syntax tree][node].
###### Example
The below example shows how the `parse` function can be used to create a
[syntax tree][node] from a [file][].
```js
var unified = require('unified')
var markdown = require('remark-parse')
var tree = unified()
.use(markdown)
.parse('# Hello world!')
console.log(tree)
```
Yields:
```js
{ type: 'root',
children:
[ { type: 'heading',
depth: 1,
children: [Array],
position: [Position] } ],
position:
{ start: { line: 1, column: 1, offset: 0 },
end: { line: 1, column: 15, offset: 14 } } }
```
#### `processor.Parser`

@@ -372,2 +405,30 @@

`stringify` does not apply [transformers from the run phase][description]
to the [syntax tree][node].
###### Example
The below example shows how the `stringify` function can be used to generate a
[file][] from a [syntax tree][node].
```js
var unified = require('unified')
var html = require('rehype-stringify')
var h = require('hastscript')
var tree = h('h1', 'Hello world!')
var doc = unified()
.use(html)
.stringify(tree)
console.log(doc)
```
Yields:
```html
<h1>Hello world!</h1>
```
#### `processor.Compiler`

@@ -406,3 +467,3 @@

##### `function done(err[, node, file])`
#### `function done(err[, node, file])`

@@ -418,2 +479,38 @@ Invoked when transformation is complete. Either invoked with an error or a

###### Example
The below example shows how the `stringify` function can be used to transform a
[syntax tree][node].
```js
var unified = require('unified')
var references = require('remark-reference-links')
var u = require('unist-builder')
var tree = u('root', [
u('paragraph', [
u('link', {href: 'https://example.com'}, [u('text', 'Example Domain')])
])
])
unified()
.use(references)
.run(tree, function(err, tree) {
if (err) throw err
console.log(tree)
})
```
Yields:
```js
{ type: 'root',
children:
[ { type: 'paragraph', children: [Array] },
{ type: 'definition',
identifier: '1',
title: undefined,
url: undefined } ] }
```
### `processor.runSync(node[, file])`

@@ -459,14 +556,7 @@

#### `function done(err, file)`
###### Example
Invoked when the process is complete. Invoked with a fatal error, if any, and
the [`VFile`][file].
The below example shows how the `process` function can be used to process a
[file][] whether plugins are asynchronous or not with Promises.
###### Parameters
* `err` (`Error`, optional) — Fatal error
* `file` ([`VFile`][file])
###### Example
```js

@@ -512,2 +602,41 @@ var unified = require('unified')

#### `function done(err, file)`
Invoked when the process is complete. Invoked with a fatal error, if any, and
the [`VFile`][file].
###### Parameters
* `err` (`Error`, optional) — Fatal error
* `file` ([`VFile`][file])
###### Example
The below example shows how the `process` function can be used to process a
[file][] whether plugins are asynchronous or not with a callback.
```js
var unified = require('unified')
var parse = require('remark-parse')
var stringify = require('remark-stringify')
var github = require('remark-github')
var report = require('vfile-reporter')
unified()
.use(parse)
.use(github)
.use(stringify)
.process('@mention', function(err, file) {
console.error(report(err || file))
console.log(String(file))
})
```
Yields:
```markdown
no issues found
[**@mention**](https://github.com/blog/821)
```
### `processor.processSync(file|value)`

@@ -535,2 +664,5 @@

The below example shows how the `processSync` function can be used to process a
[file][] if all plugins are known to be synchronous.
```js

@@ -597,15 +729,7 @@ var unified = require('unified')

console.log(
unified()
.data('alpha', 'bravo')
.data('alpha')
)
unified()
.data('alpha', 'bravo')
.data('alpha') // => 'bravo'
```
Yields:
```txt
bravo
```
### `processor.freeze()`

@@ -943,2 +1067,4 @@

[description]: #description
[file]: #file

@@ -945,0 +1071,0 @@

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