All Projects → remarkjs → remark-embed-images

remarkjs / remark-embed-images

Licence: MIT license
plugin to embed local images as data URIs

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to remark-embed-images

remark-license
plugin to generate a license section
Stars: ✭ 15 (-34.78%)
Mutual labels:  remark, remark-plugin
remark-hint
Sprinkle hints/tips/warnings on your documents
Stars: ✭ 36 (+56.52%)
Mutual labels:  remark, remark-plugin
remark-footnotes
Legacy plugin to add support for pandoc footnotes — please use `remark-gfm` instead
Stars: ✭ 38 (+65.22%)
Mutual labels:  remark, remark-plugin
remark-slate-transformer
remark plugin to transform remark syntax tree (mdast) to Slate document tree, and vice versa. Made for WYSIWYG markdown editor.
Stars: ✭ 62 (+169.57%)
Mutual labels:  remark, remark-plugin
remark-highlight.js
Legacy plugin to highlight code blocks with highlight.js — please use `rehype-highlight` instead
Stars: ✭ 58 (+152.17%)
Mutual labels:  remark, remark-plugin
remark-external-links
Legacy plugin to automatically add target and rel attributes to external links — please use `rehype-external-links` instead
Stars: ✭ 50 (+117.39%)
Mutual labels:  remark, remark-plugin
cache
A cache for @remark-embedder
Stars: ✭ 12 (-47.83%)
Mutual labels:  remark, remark-plugin
twoslash
You take some Shiki, add a hint of TypeScript compiler, and 🎉 incredible static code samples
Stars: ✭ 596 (+2491.3%)
Mutual labels:  remark, remark-plugin
remark-bookmarks
plugin to manage links
Stars: ✭ 15 (-34.78%)
Mutual labels:  remark, remark-plugin
remark-man
plugin to compile markdown to man pages
Stars: ✭ 87 (+278.26%)
Mutual labels:  remark, remark-plugin
remark-directive
remark plugin to support directives
Stars: ✭ 137 (+495.65%)
Mutual labels:  remark, remark-plugin
remark-frontmatter
remark plugin to support frontmatter (YAML, TOML, and more)
Stars: ✭ 167 (+626.09%)
Mutual labels:  remark, remark-plugin
remark-admonitions
Add admonitions support to Remarkable
Stars: ✭ 90 (+291.3%)
Mutual labels:  remark, remark-plugin
remark-behead
Remark plugin to increase or decrease markdown heading weight.
Stars: ✭ 14 (-39.13%)
Mutual labels:  remark, remark-plugin
transformer-oembed
@remark-embedder transformer for oEmbed supported links
Stars: ✭ 25 (+8.7%)
Mutual labels:  remark, remark-plugin
strip-markdown
plugin remove Markdown formatting
Stars: ✭ 84 (+265.22%)
Mutual labels:  remark, remark-plugin
remark-autolink-headings
Legacy remark plugin to automatically add links to headings — please use `rehype-autolink-headings` instead
Stars: ✭ 63 (+173.91%)
Mutual labels:  remark, remark-plugin
gatsby-remark-images-grid
Use css grid layouts in markdown
Stars: ✭ 22 (-4.35%)
Mutual labels:  remark-plugin
Mdx
Markdown for the component era
Stars: ✭ 11,948 (+51847.83%)
Mutual labels:  remark
React Markdown
Markdown component for React
Stars: ✭ 8,047 (+34886.96%)
Mutual labels:  remark

remark-embed-images

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to embed local images as data URIs.

Contents

What is this?

This package is a unified (remark) plugin that inlines images as data URIs.

unified is a project that transforms content with abstract syntax trees (ASTs). remark adds support for markdown to unified. mdast is the markdown AST that remark uses. This is a remark plugin that transforms mdast.

When should I use this?

You can use this package when you want to move markdown that references local images around more easily, because images will be inlined. This does makes the markdown quite hard to read and isn’t supported everywhere (such as GitHub), because data URIs might result in security risks.

Install

This package is ESM only. In Node.js (version 12.20+, 14.14+, or 16.0+), install with npm:

npm install remark-embed-images

In Deno with esm.sh:

import remarkEmbedImages from 'https://esm.sh/remark-embed-images@3'

In browsers with esm.sh:

<script type="module">
  import remarkEmbedImages from 'https://esm.sh/remark-embed-images@3?bundle'
</script>

Use

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

![A pink square](./foo.png)

And our module example.js looks as follows:

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

main()

async function main() {
  const file = await remark()
    .use(remarkEmbedImages)
    .process(await read('example.md'))

  console.log(String(file))
}

Now running node example.js yields:

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

API

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

unified().use(remarkEmbedImages)

Plugin to embed local images as data URIs. There are no options.

Types

This package is fully typed with TypeScript. There are no extra exported types.

Compatibility

Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js 12.20+, 14.14+, and 16.0+. Our projects sometimes work with older versions, but this is not guaranteed.

This plugin works with unified version 6+ and remark version 7+.

Security

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.

Related

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].