Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer Compromise.Details
Socket
Book a DemoInstallSign in
Socket

markdown-it-class

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-class

Plugin for markdown-it to allow adding classes to HTML tags.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

markdown-it-class

Plugin for markdown-it to allow adding classes to HTML tags.

Install

You can install it using yarn or npm

npm install --save-dev markdown-it-class

Usage

All you have to do is register the plugin and pass the tag to class mapping.

const MarkdownIt = require('markdown-it')
const markdownItClass = require('markdown-it-class')

// Setup the markdown renderer
const md = MarkdownIt()
  // Register the plugin and pass a tag to class mapping
  .use(markdownItClass, {
    h1: ['text-2xl', 'font-bold', 'mb-3', 'text-blue-700'],
    p: ['text-md'],
  });

const markdownString = fs.readFileSync('post.md', 'utf-8');
const html = md.render(markdownString);

// HTML with classes assigned to the tags
console.log(html);

Credits

This package is a fork of HiroshiOkada/markdown-it-class with the support for all sorts of HTML tags. The original package has the invalid conditional logic for assigning classes due to which it misses several HTML tags.

Contributions

Feel free to submit pull requests, create issues or spread the word.

License

MIT © Kamran Ahmed

Keywords

markdown-it

FAQs

Package last updated on 28 Aug 2022

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