Skip to content
plugin to add an improved image syntax
JavaScript
Branch: master
Clone or download

Latest commit

Latest commit 34fdfa2 Mar 23, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig Add `.editorconfig` Jun 19, 2019
.gitignore Add tests, build, checks Jun 19, 2019
.npmrc Add `.npmrc` Jun 19, 2019
.prettierignore Add tests, build, checks Jun 19, 2019
.travis.yml Add tests, build, checks Jun 19, 2019
index.js Update dev-dependencies Mar 23, 2020
license Update license Feb 28, 2019
package.json 2.0.0 Mar 23, 2020
readme.md Refactor prose Mar 23, 2020
test.js Update dev-dependencies Mar 23, 2020

readme.md

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:

  • https://example.com/image.jpg
  • /image.jpg
  • ./image.jpg
  • ../image.jpg

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

You can’t perform that action at this time.