unified

Project:remarkjs/remark-images

Package:remark-images@2.0.0

  1. Dependencies:3·Dependents:28
  2. remark plugin to add an improved image syntax
  1. remark 180
  2. unified 131
  3. plugin 122
  4. markdown 101
  5. mdast 69
  6. remark-plugin 62
  7. mdx 23
  8. react 21
  9. jsx 18
  10. image 12
  11. mdxast 10

remark-images

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to add an improved image syntax.

Install

npm:

npm install remark-images

Use

Say we have the following file, example.md:

#### A url

Below will render an image:

https://c8r-x0.s3.amazonaws.com/lab-components-macbook.jpg

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

const vfile = require('to-vfile')
const remark = require('remark')
const images = require('remark-images')

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

Now, running node example yields:

#### A url

Below will render an image:

[![](https://c8r-x0.s3.amazonaws.com/lab-components-macbook.jpg)](https://c8r-x0.s3.amazonaws.com/lab-components-macbook.jpg)

API

remark().use(images)

Add an improved image syntax. Transform URLs in text that reference images (png, svg, jpg, jpeg, or gif) to images.

Supported URLs / URIs:

Security

Although this plugin should be safe to use, always be careful with user input. For example, it’s possible to hide JavaScript inside images (such as GIFs, WebPs, and SVGs). User provided images open you up to a cross-site scripting (XSS) attack.

This may become a problem if the Markdown later transformed to rehype (hast) or opened in an unsafe Markdown viewer.

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 © John Otander