diff --git a/LICENSE b/LICENSE index 3409824..389482d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 Eugene Sharygin +Copyright (c) 2015, 2016 Eugene Sharygin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 2567a5d..3169c82 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,41 @@ -[![npm](https://nodei.co/npm/mdast-squeeze-paragraphs.png)](https://npmjs.com/package/mdast-squeeze-paragraphs) +[![npm](https://nodei.co/npm/remark-squeeze-paragraphs.png)](https://npmjs.com/package/remark-squeeze-paragraphs) -# mdast-squeeze-paragraphs +# remark-squeeze-paragraphs [![Build Status][travis-badge]][travis] [![Dependency Status][david-badge]][david] -Remove empty paragraphs left from other [mdast] transformations. +[Remark] plugin for removing empty paragraphs. -Paragraph is considered empty if it is composed from whitespace characters. +Paragraph is considered empty if it is composed of whitespace characters only. +[remark]: https://github.com/wooorm/remark [mdast]: https://github.com/wooorm/mdast +[mdast-squeeze-paragraphs]: https://github.com/eush77/mdast-squeeze-paragraphs -[travis]: https://travis-ci.org/eush77/mdast-squeeze-paragraphs -[travis-badge]: https://travis-ci.org/eush77/mdast-squeeze-paragraphs.svg -[david]: https://david-dm.org/eush77/mdast-squeeze-paragraphs -[david-badge]: https://david-dm.org/eush77/mdast-squeeze-paragraphs.png +[travis]: https://travis-ci.org/eush77/remark-squeeze-paragraphs +[travis-badge]: https://travis-ci.org/eush77/remark-squeeze-paragraphs.svg +[david]: https://david-dm.org/eush77/remark-squeeze-paragraphs +[david-badge]: https://david-dm.org/eush77/remark-squeeze-paragraphs.png ## Example ```js -> mdastSqueezeParagraphs = require('mdast-squeeze-paragraphs') +var squeezeParagraphs = require('remark-squeeze-paragraphs'); -> mdast.use(mdastStripBadges) - .process('![](http://img.shields.io/)\n\ntext') -'\n\ntext\n' +remark.use(stripBadges) + .process('![](http://img.shields.io/)\n\ntext') +//=> "\n\ntext\n" -> mdast.use(mdastStripBadges) - .use(mdastSqueezeParagraphs) - .process('![](http://img.shields.io/)\n\ntext') -'text\n' +remark.use(stripBadges) + .use(squeezeParagraphs) + .process('![](http://img.shields.io/)\n\ntext') +//=> "text\n" ``` ## API ```js -var mdastSqueezeParagraphs = require('mdast-squeeze-paragraphs'); - -mdast.use(mdastSqueezeParagraphs) +remark.use(squeezeParagraphs) ``` Modifies AST in-place. @@ -43,13 +43,17 @@ Modifies AST in-place. ## CLI ``` -mdast -u mdast-squeeze-paragraphs +remark -u remark-squeeze-paragraphs ``` +## Related + +- [mdast-squeeze-paragraphs] — [mdast] transformation utility that is in the core of this plugin. + ## Install ``` -npm install mdast-squeeze-paragraphs +npm install remark-squeeze-paragraphs ``` ## License diff --git a/index.js b/index.js index 9d0b248..3de310a 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,8 @@ 'use strict'; +var squeezeParagraphs = require('mdast-squeeze-paragraphs'); -module.exports = function () { - return function (ast) { - ast.children = ast.children.filter(function (node) { - return node.type != 'paragraph' || node.children.some(function (node) { - return node.type != 'text' || !/^\s*$/.test(node.value); - }); - }); - return ast; - }; +module.exports = function () { + return squeezeParagraphs; }; diff --git a/package.json b/package.json index e8e35cd..9409a48 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "mdast-squeeze-paragraphs", + "name": "remark-squeeze-paragraphs", "version": "1.1.0", - "description": "Remove empty paragraphs left from other mdast transformations", + "description": "Remark plugin for removing empty paragraphs", "author": "Eugene Sharygin ", "license": "MIT", "scripts": { @@ -10,30 +10,27 @@ "files": [ "index.js" ], - "homepage": "https://github.com/eush77/mdast-squeeze-paragraphs", - "repository": "eush77/mdast-squeeze-paragraphs", + "homepage": "https://github.com/eush77/remark-squeeze-paragraphs", + "repository": "eush77/remark-squeeze-paragraphs", "bugs": { - "url": "https://github.com/eush77/mdast-squeeze-paragraphs/issues" + "url": "https://github.com/eush77/remark-squeeze-paragraphs/issues" }, "keywords": [ - "mdast", - "plugin", - "markdown", - "squeeze", - "remove", + "clean", "empty", + "markdown", "paragraph", - "whitespace", - "ast", - "transform", - "transformation", - "util", - "clean" + "plugin", + "remark", + "remove", + "squeeze", + "whitespace" ], - "dependencies": {}, + "dependencies": { + "mdast-squeeze-paragraphs": "^3.0.0" + }, "devDependencies": { - "clone": "^1.0.2", - "mdast": "^0.26.2", + "remark": "^3.1.3", "tape": "^4.0.0" } } diff --git a/test/test.js b/test/test.js index 6ec56bc..7fe66a1 100644 --- a/test/test.js +++ b/test/test.js @@ -1,16 +1,15 @@ 'use strict'; -var mdastSqueezeParagraphs = require('..'); +var squeezeParagraphs = require('..'); var test = require('tape'), - mdast = require('mdast'), - clone = require('clone'); + remark = require('remark'); test(function (t) { var input = require('./input'); var output = require('./output'); - t.deepEqual(mdast.use(mdastSqueezeParagraphs).run(input), output); + t.deepEqual(remark.use(squeezeParagraphs).run(input), output); t.end(); });