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

vite-remark-html

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-remark-html

Process markdown with remark-html

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13K
decreased by-10.86%
Maintainers
1
Weekly downloads
 
Created
Source

vite-remark-html

npm Code style: Prettier Donate

Process markdown with remark-html

Basically, when you import a .md file, you'll get back a JS module with an HTML string as its default export. There are various options to customize the HTML output.

 

Usage

import remarkHtml from 'vite-remark-html'

export default {
  plugins: [remarkHtml()],
}

Filter options

Markdown files can be filtered, in case you only want a subset to be processed by this plugin. For more details, see here.

remarkHtml({
  exclude: /\/node_modules\//
})

HTML options

All options listed here are also supported.

remarkHtml({
  allowDangerousHtml: true
})

Using the HTML

In your client code, you can use import or dynamic import() to load the HTML string.

import html from './test.md'
// or
const htmlPromise = import('./test.md').then(module => module.default)

Then you can use that as the innerHTML of another element.

document.getElementById('markdown').innerHTML = html
// or
<div dangerouslySetInnerHtml={{ __html: html }} />

Try the demo to see it in action.

TypeScript usage

In your tsconfig.json

{
  "compilerOptions": {
    "types": ["vite-remark-html/client"]
  }
}

This lets you import .md files with type-checking support.

Keywords

FAQs

Package last updated on 22 Jul 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