🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
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.2.0
Source
npm
Version published
Weekly downloads
5.2K
-27.54%
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))
// <h1 class="title">Hello</h1>

Add more than one classes

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 13 Oct 2019

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