remark plugin to remove the wrapping paragraph for images.
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!
npm:
npm install remark-unwrap-images
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">
Remove the wrapping paragraph for images. Supports multiple images, white space around images, and images in links as well.
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.
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.
MIT © Compositor and Vercel, Inc.