Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remark-embed-images

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-embed-images

remark plugin to embed images with data URIs, inlining base64-encoded sources

  • 3.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.4K
decreased by-24.02%
Maintainers
2
Weekly downloads
 
Created
Source

remark-embed-images

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to embed local images as data URIs, inlining files as base64-encoded values.

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

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install remark-embed-images

Use

Say we have an image, foo.png, and next to it the following file, example.md:

![A PNG file](./foo.png)

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

import {readSync} from 'to-vfile'
import {remark} from 'remark'
import remarkEmbedImages from 'remark-embed-images'

const file = readSync('example.md')

remark()
  .use(remarkEmbedImages)
  .process(file)
  .then((file) => {
    console.log(String(file))
  })

Now, running node example yields:

![A PNG file](data:image/png;base64,iVBORw0…)

API

This package exports no identifiers. The default export is remarkEmbedImages.

unified().use(remarkEmbedImages)

Embed local images as data URIs, inlining files as base64-encoded values.

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.

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 © David Herges

Keywords

FAQs

Package last updated on 03 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc