Comparing version 6.1.6 to 6.2.0
340
index.js
@@ -1,35 +0,37 @@ | ||
'use strict'; | ||
'use strict' | ||
/* Dependencies. */ | ||
var extend = require('extend'); | ||
var bail = require('bail'); | ||
var vfile = require('vfile'); | ||
var trough = require('trough'); | ||
var string = require('x-is-string'); | ||
var func = require('x-is-function'); | ||
var plain = require('is-plain-obj'); | ||
var extend = require('extend') | ||
var bail = require('bail') | ||
var vfile = require('vfile') | ||
var trough = require('trough') | ||
var string = require('x-is-string') | ||
var plain = require('is-plain-obj') | ||
/* Expose a frozen processor. */ | ||
module.exports = unified().freeze(); | ||
module.exports = unified().freeze() | ||
var slice = [].slice; | ||
var own = {}.hasOwnProperty; | ||
var slice = [].slice | ||
var own = {}.hasOwnProperty | ||
/* Process pipeline. */ | ||
var pipeline = trough().use(pipelineParse).use(pipelineRun).use(pipelineStringify); | ||
var pipeline = trough() | ||
.use(pipelineParse) | ||
.use(pipelineRun) | ||
.use(pipelineStringify) | ||
function pipelineParse(p, ctx) { | ||
ctx.tree = p.parse(ctx.file); | ||
ctx.tree = p.parse(ctx.file) | ||
} | ||
function pipelineRun(p, ctx, next) { | ||
p.run(ctx.tree, ctx.file, done); | ||
p.run(ctx.tree, ctx.file, done) | ||
function done(err, tree, file) { | ||
if (err) { | ||
next(err); | ||
next(err) | ||
} else { | ||
ctx.tree = tree; | ||
ctx.file = file; | ||
next(); | ||
ctx.tree = tree | ||
ctx.file = file | ||
next() | ||
} | ||
@@ -40,3 +42,3 @@ } | ||
function pipelineStringify(p, ctx) { | ||
ctx.file.contents = p.stringify(ctx.tree, ctx.file); | ||
ctx.file.contents = p.stringify(ctx.tree, ctx.file) | ||
} | ||
@@ -46,28 +48,28 @@ | ||
function unified() { | ||
var attachers = []; | ||
var transformers = trough(); | ||
var namespace = {}; | ||
var frozen = false; | ||
var freezeIndex = -1; | ||
var attachers = [] | ||
var transformers = trough() | ||
var namespace = {} | ||
var frozen = false | ||
var freezeIndex = -1 | ||
/* Data management. */ | ||
processor.data = data; | ||
processor.data = data | ||
/* Lock. */ | ||
processor.freeze = freeze; | ||
processor.freeze = freeze | ||
/* Plug-ins. */ | ||
processor.attachers = attachers; | ||
processor.use = use; | ||
processor.attachers = attachers | ||
processor.use = use | ||
/* API. */ | ||
processor.parse = parse; | ||
processor.stringify = stringify; | ||
processor.run = run; | ||
processor.runSync = runSync; | ||
processor.process = process; | ||
processor.processSync = processSync; | ||
processor.parse = parse | ||
processor.stringify = stringify | ||
processor.run = run | ||
processor.runSync = runSync | ||
processor.process = process | ||
processor.processSync = processSync | ||
/* Expose. */ | ||
return processor; | ||
return processor | ||
@@ -77,13 +79,13 @@ /* Create a new processor based on the processor | ||
function processor() { | ||
var destination = unified(); | ||
var length = attachers.length; | ||
var index = -1; | ||
var destination = unified() | ||
var length = attachers.length | ||
var index = -1 | ||
while (++index < length) { | ||
destination.use.apply(null, attachers[index]); | ||
destination.use.apply(null, attachers[index]) | ||
} | ||
destination.data(extend(true, {}, namespace)); | ||
destination.data(extend(true, {}, namespace)) | ||
return destination; | ||
return destination | ||
} | ||
@@ -101,36 +103,36 @@ | ||
function freeze() { | ||
var values; | ||
var plugin; | ||
var options; | ||
var transformer; | ||
var values | ||
var plugin | ||
var options | ||
var transformer | ||
if (frozen) { | ||
return processor; | ||
return processor | ||
} | ||
while (++freezeIndex < attachers.length) { | ||
values = attachers[freezeIndex]; | ||
plugin = values[0]; | ||
options = values[1]; | ||
transformer = null; | ||
values = attachers[freezeIndex] | ||
plugin = values[0] | ||
options = values[1] | ||
transformer = null | ||
if (options === false) { | ||
continue; | ||
continue | ||
} | ||
if (options === true) { | ||
values[1] = undefined; | ||
values[1] = undefined | ||
} | ||
transformer = plugin.apply(processor, values.slice(1)); | ||
transformer = plugin.apply(processor, values.slice(1)) | ||
if (func(transformer)) { | ||
transformers.use(transformer); | ||
if (typeof transformer === 'function') { | ||
transformers.use(transformer) | ||
} | ||
} | ||
frozen = true; | ||
freezeIndex = Infinity; | ||
frozen = true | ||
freezeIndex = Infinity | ||
return processor; | ||
return processor | ||
} | ||
@@ -144,11 +146,11 @@ | ||
if (arguments.length === 2) { | ||
assertUnfrozen('data', frozen); | ||
assertUnfrozen('data', frozen) | ||
namespace[key] = value; | ||
namespace[key] = value | ||
return processor; | ||
return processor | ||
} | ||
/* Get `key`. */ | ||
return (own.call(namespace, key) && namespace[key]) || null; | ||
return (own.call(namespace, key) && namespace[key]) || null | ||
} | ||
@@ -158,9 +160,9 @@ | ||
if (key) { | ||
assertUnfrozen('data', frozen); | ||
namespace = key; | ||
return processor; | ||
assertUnfrozen('data', frozen) | ||
namespace = key | ||
return processor | ||
} | ||
/* Get space. */ | ||
return namespace; | ||
return namespace | ||
} | ||
@@ -176,31 +178,31 @@ | ||
function use(value) { | ||
var settings; | ||
var settings | ||
assertUnfrozen('use', frozen); | ||
assertUnfrozen('use', frozen) | ||
if (value === null || value === undefined) { | ||
/* Empty */ | ||
} else if (func(value)) { | ||
addPlugin.apply(null, arguments); | ||
} else if (typeof value === 'function') { | ||
addPlugin.apply(null, arguments) | ||
} else if (typeof value === 'object') { | ||
if ('length' in value) { | ||
addList(value); | ||
addList(value) | ||
} else { | ||
addPreset(value); | ||
addPreset(value) | ||
} | ||
} else { | ||
throw new Error('Expected usable value, not `' + value + '`'); | ||
throw new Error('Expected usable value, not `' + value + '`') | ||
} | ||
if (settings) { | ||
namespace.settings = extend(namespace.settings || {}, settings); | ||
namespace.settings = extend(namespace.settings || {}, settings) | ||
} | ||
return processor; | ||
return processor | ||
function addPreset(result) { | ||
addList(result.plugins); | ||
addList(result.plugins) | ||
if (result.settings) { | ||
settings = extend(settings || {}, result.settings); | ||
settings = extend(settings || {}, result.settings) | ||
} | ||
@@ -210,12 +212,12 @@ } | ||
function add(value) { | ||
if (func(value)) { | ||
addPlugin(value); | ||
if (typeof value === 'function') { | ||
addPlugin(value) | ||
} else if (typeof value === 'object') { | ||
if ('length' in value) { | ||
addPlugin.apply(null, value); | ||
addPlugin.apply(null, value) | ||
} else { | ||
addPreset(value); | ||
addPreset(value) | ||
} | ||
} else { | ||
throw new Error('Expected usable value, not `' + value + '`'); | ||
throw new Error('Expected usable value, not `' + value + '`') | ||
} | ||
@@ -225,4 +227,4 @@ } | ||
function addList(plugins) { | ||
var length; | ||
var index; | ||
var length | ||
var index | ||
@@ -232,10 +234,10 @@ if (plugins === null || plugins === undefined) { | ||
} else if (typeof plugins === 'object' && 'length' in plugins) { | ||
length = plugins.length; | ||
index = -1; | ||
length = plugins.length | ||
index = -1 | ||
while (++index < length) { | ||
add(plugins[index]); | ||
add(plugins[index]) | ||
} | ||
} else { | ||
throw new Error('Expected a list of plugins, not `' + plugins + '`'); | ||
throw new Error('Expected a list of plugins, not `' + plugins + '`') | ||
} | ||
@@ -245,12 +247,12 @@ } | ||
function addPlugin(plugin, value) { | ||
var entry = find(plugin); | ||
var entry = find(plugin) | ||
if (entry) { | ||
if (plain(entry[1]) && plain(value)) { | ||
value = extend(entry[1], value); | ||
value = extend(entry[1], value) | ||
} | ||
entry[1] = value; | ||
entry[1] = value | ||
} else { | ||
attachers.push(slice.call(arguments)); | ||
attachers.push(slice.call(arguments)) | ||
} | ||
@@ -261,11 +263,11 @@ } | ||
function find(plugin) { | ||
var length = attachers.length; | ||
var index = -1; | ||
var entry; | ||
var length = attachers.length | ||
var index = -1 | ||
var entry | ||
while (++index < length) { | ||
entry = attachers[index]; | ||
entry = attachers[index] | ||
if (entry[0] === plugin) { | ||
return entry; | ||
return entry | ||
} | ||
@@ -279,14 +281,14 @@ } | ||
function parse(doc) { | ||
var file = vfile(doc); | ||
var Parser; | ||
var file = vfile(doc) | ||
var Parser | ||
freeze(); | ||
Parser = processor.Parser; | ||
assertParser('parse', Parser); | ||
freeze() | ||
Parser = processor.Parser | ||
assertParser('parse', Parser) | ||
if (newable(Parser)) { | ||
return new Parser(String(file), file).parse(); | ||
return new Parser(String(file), file).parse() | ||
} | ||
return Parser(String(file), file); // eslint-disable-line new-cap | ||
return Parser(String(file), file) // eslint-disable-line new-cap | ||
} | ||
@@ -297,27 +299,27 @@ | ||
function run(node, file, cb) { | ||
assertNode(node); | ||
freeze(); | ||
assertNode(node) | ||
freeze() | ||
if (!cb && func(file)) { | ||
cb = file; | ||
file = null; | ||
if (!cb && typeof file === 'function') { | ||
cb = file | ||
file = null | ||
} | ||
if (!cb) { | ||
return new Promise(executor); | ||
return new Promise(executor) | ||
} | ||
executor(null, cb); | ||
executor(null, cb) | ||
function executor(resolve, reject) { | ||
transformers.run(node, vfile(file), done); | ||
transformers.run(node, vfile(file), done) | ||
function done(err, tree, file) { | ||
tree = tree || node; | ||
tree = tree || node | ||
if (err) { | ||
reject(err); | ||
reject(err) | ||
} else if (resolve) { | ||
resolve(tree); | ||
resolve(tree) | ||
} else { | ||
cb(null, tree, file); | ||
cb(null, tree, file) | ||
} | ||
@@ -331,15 +333,15 @@ } | ||
function runSync(node, file) { | ||
var complete = false; | ||
var result; | ||
var complete = false | ||
var result | ||
run(node, file, done); | ||
run(node, file, done) | ||
assertDone('runSync', 'run', complete); | ||
assertDone('runSync', 'run', complete) | ||
return result; | ||
return result | ||
function done(err, tree) { | ||
complete = true; | ||
bail(err); | ||
result = tree; | ||
complete = true | ||
bail(err) | ||
result = tree | ||
} | ||
@@ -352,15 +354,15 @@ } | ||
function stringify(node, doc) { | ||
var file = vfile(doc); | ||
var Compiler; | ||
var file = vfile(doc) | ||
var Compiler | ||
freeze(); | ||
Compiler = processor.Compiler; | ||
assertCompiler('stringify', Compiler); | ||
assertNode(node); | ||
freeze() | ||
Compiler = processor.Compiler | ||
assertCompiler('stringify', Compiler) | ||
assertNode(node) | ||
if (newable(Compiler)) { | ||
return new Compiler(node, file).compile(); | ||
return new Compiler(node, file).compile() | ||
} | ||
return Compiler(node, file); // eslint-disable-line new-cap | ||
return Compiler(node, file) // eslint-disable-line new-cap | ||
} | ||
@@ -374,24 +376,24 @@ | ||
function process(doc, cb) { | ||
freeze(); | ||
assertParser('process', processor.Parser); | ||
assertCompiler('process', processor.Compiler); | ||
freeze() | ||
assertParser('process', processor.Parser) | ||
assertCompiler('process', processor.Compiler) | ||
if (!cb) { | ||
return new Promise(executor); | ||
return new Promise(executor) | ||
} | ||
executor(null, cb); | ||
executor(null, cb) | ||
function executor(resolve, reject) { | ||
var file = vfile(doc); | ||
var file = vfile(doc) | ||
pipeline.run(processor, {file: file}, done); | ||
pipeline.run(processor, {file: file}, done) | ||
function done(err) { | ||
if (err) { | ||
reject(err); | ||
reject(err) | ||
} else if (resolve) { | ||
resolve(file); | ||
resolve(file) | ||
} else { | ||
cb(null, file); | ||
cb(null, file) | ||
} | ||
@@ -405,19 +407,19 @@ } | ||
function processSync(doc) { | ||
var complete = false; | ||
var file; | ||
var complete = false | ||
var file | ||
freeze(); | ||
assertParser('processSync', processor.Parser); | ||
assertCompiler('processSync', processor.Compiler); | ||
file = vfile(doc); | ||
freeze() | ||
assertParser('processSync', processor.Parser) | ||
assertCompiler('processSync', processor.Compiler) | ||
file = vfile(doc) | ||
process(file, done); | ||
process(file, done) | ||
assertDone('processSync', 'process', complete); | ||
assertDone('processSync', 'process', complete) | ||
return file; | ||
return file | ||
function done(err) { | ||
complete = true; | ||
bail(err); | ||
complete = true | ||
bail(err) | ||
} | ||
@@ -429,3 +431,3 @@ } | ||
function newable(value) { | ||
return func(value) && keys(value.prototype); | ||
return typeof value === 'function' && keys(value.prototype) | ||
} | ||
@@ -435,7 +437,7 @@ | ||
function keys(value) { | ||
var key; | ||
var key | ||
for (key in value) { | ||
return true; | ||
return true | ||
} | ||
return false; | ||
return false | ||
} | ||
@@ -445,4 +447,4 @@ | ||
function assertParser(name, Parser) { | ||
if (!func(Parser)) { | ||
throw new Error('Cannot `' + name + '` without `Parser`'); | ||
if (typeof Parser !== 'function') { | ||
throw new Error('Cannot `' + name + '` without `Parser`') | ||
} | ||
@@ -453,4 +455,4 @@ } | ||
function assertCompiler(name, Compiler) { | ||
if (!func(Compiler)) { | ||
throw new Error('Cannot `' + name + '` without `Compiler`'); | ||
if (typeof Compiler !== 'function') { | ||
throw new Error('Cannot `' + name + '` without `Compiler`') | ||
} | ||
@@ -463,6 +465,8 @@ } | ||
throw new Error( | ||
'Cannot invoke `' + name + '` on a frozen processor.\n' + | ||
'Create a new processor first, by invoking it: ' + | ||
'use `processor()` instead of `processor`.' | ||
); | ||
[ | ||
'Cannot invoke `' + name + '` on a frozen processor.\nCreate a new ', | ||
'processor first, by invoking it: use `processor()` instead of ', | ||
'`processor`.' | ||
].join('') | ||
) | ||
} | ||
@@ -474,3 +478,3 @@ } | ||
if (!node || !string(node.type)) { | ||
throw new Error('Expected node, got `' + node + '`'); | ||
throw new Error('Expected node, got `' + node + '`') | ||
} | ||
@@ -482,4 +486,6 @@ } | ||
if (!complete) { | ||
throw new Error('`' + name + '` finished async. Use `' + asyncName + '` instead'); | ||
throw new Error( | ||
'`' + name + '` finished async. Use `' + asyncName + '` instead' | ||
) | ||
} | ||
} |
{ | ||
"name": "unified", | ||
"version": "6.1.6", | ||
"version": "6.2.0", | ||
"description": "Pluggable text processing interface", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
], | ||
"repository": "https://github.com/unifiedjs/unified", | ||
"repository": "unifiedjs/unified", | ||
"bugs": "https://github.com/unifiedjs/unified/issues", | ||
@@ -33,23 +33,22 @@ "author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
"vfile": "^2.0.0", | ||
"x-is-function": "^1.0.4", | ||
"x-is-string": "^0.1.0" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^14.0.0", | ||
"browserify": "^16.0.0", | ||
"esmangle": "^1.0.0", | ||
"nyc": "^11.0.0", | ||
"remark-cli": "^4.0.0", | ||
"remark-preset-wooorm": "^3.0.0", | ||
"prettier": "^1.12.1", | ||
"remark-cli": "^5.0.0", | ||
"remark-preset-wooorm": "^4.0.0", | ||
"tape": "^4.4.0", | ||
"xo": "^0.18.1" | ||
"xo": "^0.20.0" | ||
}, | ||
"scripts": { | ||
"build-md": "remark . -qfo", | ||
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix", | ||
"build-bundle": "browserify index.js -s unified > unified.js", | ||
"build-mangle": "esmangle unified.js > unified.min.js", | ||
"build": "npm run build-md && npm run build-bundle && npm run build-mangle", | ||
"lint": "xo", | ||
"build": "npm run build-bundle && npm run build-mangle", | ||
"test-api": "node test", | ||
"test-coverage": "nyc --reporter lcov tape test", | ||
"test": "npm run build && npm run lint && npm run test-coverage" | ||
"test": "npm run format && npm run build && npm run test-coverage" | ||
}, | ||
@@ -62,10 +61,19 @@ "nyc": { | ||
}, | ||
"prettier": { | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": true, | ||
"bracketSpacing": false, | ||
"semi": false, | ||
"trailingComma": "none" | ||
}, | ||
"xo": { | ||
"space": true, | ||
"prettier": true, | ||
"esnext": false, | ||
"rules": { | ||
"unicorn/prefer-type-error": "off", | ||
"import/no-unassigned-import": "off", | ||
"guard-for-in": "off", | ||
"max-lines": "off" | ||
"no-var": "off", | ||
"object-shorthand": "off", | ||
"prefer-arrow-callback": "off", | ||
"unicorn/prefer-type-error": "off" | ||
}, | ||
@@ -72,0 +80,0 @@ "ignores": [ |
258
readme.md
@@ -26,9 +26,9 @@ # ![unified][logo] | ||
```js | ||
var unified = require('unified'); | ||
var markdown = require('remark-parse'); | ||
var remark2rehype = require('remark-rehype'); | ||
var doc = require('rehype-document'); | ||
var format = require('rehype-format'); | ||
var html = require('rehype-stringify'); | ||
var report = require('vfile-reporter'); | ||
var unified = require('unified') | ||
var markdown = require('remark-parse') | ||
var remark2rehype = require('remark-rehype') | ||
var doc = require('rehype-document') | ||
var format = require('rehype-format') | ||
var html = require('rehype-stringify') | ||
var report = require('vfile-reporter') | ||
@@ -41,6 +41,6 @@ unified() | ||
.use(html) | ||
.process('# Hello world!', function (err, file) { | ||
console.error(report(err || file)); | ||
console.log(String(file)); | ||
}); | ||
.process('# Hello world!', function(err, file) { | ||
console.error(report(err || file)) | ||
console.log(String(file)) | ||
}) | ||
``` | ||
@@ -82,2 +82,4 @@ | ||
* [Preset](#preset) | ||
* [Contribute](#contribute) | ||
* [Acknowledgments](#acknowledgments) | ||
* [License](#license) | ||
@@ -179,11 +181,11 @@ | ||
```js | ||
var unified = require('unified'); | ||
var markdown = require('remark-parse'); | ||
var styleGuide = require('remark-preset-lint-markdown-style-guide'); | ||
var remark2retext = require('remark-retext'); | ||
var english = require('retext-english'); | ||
var equality = require('retext-equality'); | ||
var remark2rehype = require('remark-rehype'); | ||
var html = require('rehype-stringify'); | ||
var report = require('vfile-reporter'); | ||
var unified = require('unified') | ||
var markdown = require('remark-parse') | ||
var styleGuide = require('remark-preset-lint-markdown-style-guide') | ||
var remark2retext = require('remark-retext') | ||
var english = require('retext-english') | ||
var equality = require('retext-equality') | ||
var remark2rehype = require('remark-rehype') | ||
var html = require('rehype-stringify') | ||
var report = require('vfile-reporter') | ||
@@ -193,9 +195,14 @@ unified() | ||
.use(styleGuide) | ||
.use(remark2retext, unified().use(english).use(equality)) | ||
.use( | ||
remark2retext, | ||
unified() | ||
.use(english) | ||
.use(equality) | ||
) | ||
.use(remark2rehype) | ||
.use(html) | ||
.process('*Emphasis* and _importance_, you guys!', function (err, file) { | ||
console.error(report(err || file)); | ||
console.log(String(file)); | ||
}); | ||
.process('*Emphasis* and _importance_, you guys!', function(err, file) { | ||
console.error(report(err || file)) | ||
console.log(String(file)) | ||
}) | ||
``` | ||
@@ -253,8 +260,14 @@ | ||
```js | ||
var remark = require('remark'); | ||
var concat = require('concat-stream'); | ||
var remark = require('remark') | ||
var concat = require('concat-stream') | ||
process.stdin.pipe(concat(function (buf) { | ||
process.stdout.write(remark().processSync(buf).toString()); | ||
})); | ||
process.stdin.pipe(concat(onconcat)) | ||
function onconcat(buf) { | ||
var doc = remark() | ||
.processSync(buf) | ||
.toString() | ||
process.stdout.write(doc) | ||
} | ||
``` | ||
@@ -297,3 +310,3 @@ | ||
```js | ||
var unified = require('unified'); | ||
var unified = require('unified') | ||
@@ -310,3 +323,3 @@ unified() | ||
// Settings only: | ||
.use({settings: {position: false}}); | ||
.use({settings: {position: false}}) | ||
@@ -463,8 +476,8 @@ function plugin() {} | ||
```js | ||
var unified = require('unified'); | ||
var markdown = require('remark-parse'); | ||
var remark2rehype = require('remark-rehype'); | ||
var doc = require('rehype-document'); | ||
var format = require('rehype-format'); | ||
var html = require('rehype-stringify'); | ||
var unified = require('unified') | ||
var markdown = require('remark-parse') | ||
var remark2rehype = require('remark-rehype') | ||
var doc = require('rehype-document') | ||
var format = require('rehype-format') | ||
var html = require('rehype-stringify') | ||
@@ -478,7 +491,10 @@ unified() | ||
.process('# Hello world!') | ||
.then(function (file) { | ||
console.log(String(file)); | ||
}, function (err) { | ||
console.error(String(err)); | ||
}); | ||
.then( | ||
function(file) { | ||
console.log(String(file)) | ||
}, | ||
function(err) { | ||
console.error(String(err)) | ||
} | ||
) | ||
``` | ||
@@ -524,8 +540,8 @@ | ||
```js | ||
var unified = require('unified'); | ||
var markdown = require('remark-parse'); | ||
var remark2rehype = require('remark-rehype'); | ||
var doc = require('rehype-document'); | ||
var format = require('rehype-format'); | ||
var html = require('rehype-stringify'); | ||
var unified = require('unified') | ||
var markdown = require('remark-parse') | ||
var remark2rehype = require('remark-rehype') | ||
var doc = require('rehype-document') | ||
var format = require('rehype-format') | ||
var html = require('rehype-stringify') | ||
@@ -537,5 +553,5 @@ var processor = unified() | ||
.use(format) | ||
.use(html); | ||
.use(html) | ||
console.log(processor.processSync('# Hello world!').toString()); | ||
console.log(processor.processSync('# Hello world!').toString()) | ||
``` | ||
@@ -584,5 +600,9 @@ | ||
```js | ||
var unified = require('unified'); | ||
var unified = require('unified') | ||
console.log(unified().data('alpha', 'bravo').data('alpha')) | ||
console.log( | ||
unified() | ||
.data('alpha', 'bravo') | ||
.data('alpha') | ||
) | ||
``` | ||
@@ -618,7 +638,10 @@ | ||
```js | ||
var unified = require('unified'); | ||
var parse = require('rehype-parse'); | ||
var stringify = require('rehype-stringify'); | ||
var unified = require('unified') | ||
var parse = require('rehype-parse') | ||
var stringify = require('rehype-stringify') | ||
module.exports = unified().use(parse).use(stringify).freeze(); | ||
module.exports = unified() | ||
.use(parse) | ||
.use(stringify) | ||
.freeze() | ||
``` | ||
@@ -629,4 +652,4 @@ | ||
```js | ||
var rehype = require('rehype'); | ||
var format = require('rehype-format'); | ||
var rehype = require('rehype') | ||
var format = require('rehype-format') | ||
// ... | ||
@@ -645,4 +668,4 @@ | ||
```js | ||
var rehype = require('rehype'); | ||
var format = require('rehype-format'); | ||
var rehype = require('rehype') | ||
var format = require('rehype-format') | ||
// ... | ||
@@ -686,16 +709,16 @@ | ||
```js | ||
module.exports = move; | ||
module.exports = move | ||
function move(options) { | ||
var expected = (options || {}).extname; | ||
var expected = (options || {}).extname | ||
if (!expected) { | ||
throw new Error('Missing `extname` in options'); | ||
throw new Error('Missing `extname` in options') | ||
} | ||
return transformer; | ||
return transformer | ||
function transformer(tree, file) { | ||
if (file.extname && file.extname !== expected) { | ||
file.extname = expected; | ||
file.extname = expected | ||
} | ||
@@ -709,9 +732,9 @@ } | ||
```js | ||
var unified = require('unified'); | ||
var parse = require('remark-parse'); | ||
var remark2rehype = require('remark-rehype'); | ||
var stringify = require('rehype-stringify'); | ||
var vfile = require('to-vfile'); | ||
var report = require('vfile-reporter'); | ||
var move = require('./move'); | ||
var unified = require('unified') | ||
var parse = require('remark-parse') | ||
var remark2rehype = require('remark-rehype') | ||
var stringify = require('rehype-stringify') | ||
var vfile = require('to-vfile') | ||
var report = require('vfile-reporter') | ||
var move = require('./move') | ||
@@ -723,8 +746,8 @@ unified() | ||
.use(stringify) | ||
.process(vfile.readSync('index.md'), function (err, file) { | ||
console.error(report(err || file)); | ||
.process(vfile.readSync('index.md'), function(err, file) { | ||
console.error(report(err || file)) | ||
if (file) { | ||
vfile.writeSync(file); // Written to `index.html`. | ||
vfile.writeSync(file) // Written to `index.html`. | ||
} | ||
}); | ||
}) | ||
``` | ||
@@ -806,3 +829,3 @@ | ||
```js | ||
exports.settings = {bullet: '*', fences: true}; | ||
exports.settings = {bullet: '*', fences: true} | ||
@@ -815,3 +838,3 @@ exports.plugins = [ | ||
require('remark-github') | ||
]; | ||
] | ||
``` | ||
@@ -822,18 +845,45 @@ | ||
```js | ||
var remark = require('remark'); | ||
var vfile = require('to-vfile'); | ||
var report = require('vfile-reporter'); | ||
var preset = require('./preset'); | ||
var remark = require('remark') | ||
var vfile = require('to-vfile') | ||
var report = require('vfile-reporter') | ||
var preset = require('./preset') | ||
remark() | ||
.use(preset) | ||
.process(vfile.readSync('index.md'), function (err, file) { | ||
console.error(report(err || file)); | ||
.process(vfile.readSync('index.md'), function(err, file) { | ||
console.error(report(err || file)) | ||
if (file) { | ||
vfile.writeSync(file); | ||
vfile.writeSync(file) | ||
} | ||
}); | ||
}) | ||
``` | ||
## Contribute | ||
**unified** is built by people just like you! Check out | ||
[`contributing.md`][contributing] for ways to get started. | ||
This project has a [Code of Conduct][coc]. By interacting with this repository, | ||
organisation, or community you agree to abide by its terms. | ||
Want to chat with the community and contributors? Join us in [Gitter][chat]! | ||
Have an idea for a cool new utility or tool? That’s great! If you want | ||
feedback, help, or just to share it with the world you can do so by creating | ||
an issue in the [`unifiedjs/ideas`][ideas] repository! | ||
## Acknowledgments | ||
Preliminary work for unified was done [in 2014][preliminary] for | ||
[**retext**][retext] and inspired by [`ware`][ware]. Further incubation | ||
happened in [**remark**][remark]. The project was finally [externalised][] | ||
in 2015 and [published][] as `unified`. The project was authored by | ||
[**@wooorm**](https://github.com/wooorm). | ||
Although `unified` since moved it’s plugin architecture to [`trough`][trough], | ||
thanks to [**@calvinfo**](https://github.com/calvinfo), | ||
[**@ianstormtaylor**](https://github.com/ianstormtaylor), and others for their | ||
work on [`ware`][ware], which was a huge initial inspiration. | ||
## License | ||
@@ -869,7 +919,7 @@ | ||
[rehype]: https://github.com/wooorm/rehype | ||
[rehype]: https://github.com/rehypejs/rehype | ||
[remark]: https://github.com/wooorm/remark | ||
[remark]: https://github.com/remarkjs/remark | ||
[retext]: https://github.com/wooorm/retext | ||
[retext]: https://github.com/retextjs/retext | ||
@@ -892,9 +942,9 @@ [hast]: https://github.com/syntax-tree/hast | ||
[remark-rehype]: https://github.com/wooorm/remark-rehype | ||
[remark-rehype]: https://github.com/remarkjs/remark-rehype | ||
[remark-retext]: https://github.com/wooorm/remark-retext | ||
[remark-retext]: https://github.com/remarkjs/remark-retext | ||
[rehype-retext]: https://github.com/wooorm/rehype-retext | ||
[rehype-retext]: https://github.com/rehypejs/rehype-retext | ||
[rehype-remark]: https://github.com/wooorm/rehype-remark | ||
[rehype-remark]: https://github.com/rehypejs/rehype-remark | ||
@@ -947,8 +997,22 @@ [unist-utilities]: https://github.com/syntax-tree/unist#list-of-utilities | ||
[remark-plugins]: https://github.com/wooorm/remark/blob/master/doc/plugins.md#list-of-plugins | ||
[remark-plugins]: https://github.com/remarkjs/remark/blob/master/doc/plugins.md#list-of-plugins | ||
[rehype-plugins]: https://github.com/wooorm/rehype/blob/master/doc/plugins.md#list-of-plugins | ||
[rehype-plugins]: https://github.com/rehypejs/rehype/blob/master/doc/plugins.md#list-of-plugins | ||
[retext-plugins]: https://github.com/wooorm/retext/blob/master/doc/plugins.md#list-of-plugins | ||
[retext-plugins]: https://github.com/retextjs/retext/blob/master/doc/plugins.md#list-of-plugins | ||
[stream]: https://github.com/unifiedjs/unified-stream | ||
[contributing]: contributing.md | ||
[coc]: code-of-conduct.md | ||
[ideas]: https://github.com/unifiedjs/ideas | ||
[preliminary]: https://github.com/retextjs/retext/commit/8fcb1f#diff-168726dbe96b3ce427e7fedce31bb0bc | ||
[externalised]: https://github.com/remarkjs/remark/commit/9892ec#diff-168726dbe96b3ce427e7fedce31bb0bc | ||
[published]: https://github.com/unifiedjs/unified/commit/2ba1cf | ||
[ware]: https://github.com/segmentio/ware |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
40528
6
378
994
8
1
- Removedx-is-function@^1.0.4
- Removedx-is-function@1.0.4(transitive)