unified

Project:remarkjs/remark-unwrap-images

Package:remark-unwrap-images@2.0.0

  1. Dependencies:2·Dependents:32
  2. remark plugin to remove the wrapping paragraph for images
  1. remark 180
  2. unified 131
  3. plugin 122
  4. markdown 101
  5. mdast 69
  6. remark-plugin 62
  7. image 12

remark-unwrap-images

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to remove the wrapping paragraph for images.

Install

npm:

npm install remark-unwrap-images

Use

Say we have the following file, example.md. Imagine section titles and URLs a bit longer though.

![hi](there.png)

And our script, example.js, looks as follows:

var vfile = require('to-vfile')
var remark = require('remark')
var html = require('remark-html')
var unwrapImages = require('remark-unwrap-images')

remark()
  .use(unwrapImages)
  .use(html)
  .process(vfile.readSync('example.md'), function(err, file) {
    if (err) throw err
    console.log(String(file))
  })

Now, running node example yields:

<img src="there.png" alt="hi">

API

remark().use(unwrapImages)

Remove the wrapping paragraph for images. Supports multiple images, white space around images, and images in links as well.

Security

Use of remark-unwrap-images does not involve rehype (hast) or user content, it only removes some existing nodes, so there are no openings for cross-site scripting (XSS) attacks.

Contribute

See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Compositor and ZEIT, Inc.