Skip to content

Latest commit

 

History

History
133 lines (84 loc) · 3.37 KB

readme.md

File metadata and controls

133 lines (84 loc) · 3.37 KB

remark-unwrap-images

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to remove the wrapping paragraph for images.

Note!

This plugin is ready for the new parser in remark (remarkjs/remark#536). No change is needed: it works exactly the same now as it did before!

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 Vercel, Inc.