You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@toycode/markdown-it-class

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@toycode/markdown-it-class

A markdown-it plugin that add classes by tag name

1.0.2
Source
npmnpm
Version published
Weekly downloads
7.2K
-4.04%
Maintainers
1
Weekly downloads
 
Created
Source

markdown-it-class

This is a plugin for the markdown-it markdown parser. This plugin add class attributes to html elements.

Install

npm install @toycode/markdown-it-class --save-dev

Although it will work with "yarn", I have not tried it.


Use
---

### Add title class to h1 element

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

const mdText = '# Hello' const mapping = { h1: 'title' } const md = MarkdownIt().use(markdownItClass, mapping) console.log(md.render(mdText)) //

Hello


### Add more than one classes

```js
const MarkdownIt = require('markdown-it')
const markdownItClass = require('@toycode/markdown-it-class')

const mdText = '# Hello\n## *Markdown* world'
const mapping = { h1: ['title', 'is-4'], h2: 'subtitle', em: 'tag' }
const md = MarkdownIt().use(markdownItClass, mapping)
console.log(md.render(mdText))
// <h1 class="title is-4">Hello</h1>
// <h2 class="subtitle"><em class="tag">Markdown</em> world</h2>

Keywords

markdown-it

FAQs

Package last updated on 20 Aug 2018

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