🚀 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 - npm Package Compare versions

Comparing version

to
1.2.0

CHANGELOG.md

2

index.js

@@ -11,3 +11,3 @@ 'use strict'

tokens.forEach(token => {
if (/_open$/.test(token.type) && mapping[token.tag]) {
if (/(_open$|image)/.test(token.type) && mapping[token.tag]) {
const orig = splitWithSpace(token.attrGet('class'))

@@ -14,0 +14,0 @@ const addition = toArray(mapping[token.tag])

@@ -6,3 +6,3 @@ const MarkdownIt = require('markdown-it')

describe('markdown-it-class', () => {
it('add a class to corresponding tags', () => {
it('adds a class to corresponding tags', () => {
const mapping = {

@@ -22,3 +22,3 @@ h1: 'title',

it('add classes to corresponding tags', () => {
it('adds classes to corresponding tags', () => {
const mapping = {

@@ -38,9 +38,9 @@ h1: ['title', 'is-4'],

it('add classes to em tags', () => {
it('adds classes to em tags', () => {
const mapping = {
em: 'tag',
},
mdtxt = '# Thre are three buttons, *red* *green* and *blue*.'
mdtxt = '# There are three buttons, *red* *green* and *blue*.'
htmltxt =
'<h1>Thre are three buttons, <em class="tag">red</em> <em class="tag">green</em> and <em class="tag">blue</em>.</h1>'
'<h1>There are three buttons, <em class="tag">red</em> <em class="tag">green</em> and <em class="tag">blue</em>.</h1>'

@@ -52,4 +52,18 @@ const md = new MarkdownIt()

})
it('adds classes to img tags', () => {
const mapping = {
img: 'tag',
},
mdtxt = '![alt text](http://placehold.it/720x480.jpg)'
htmltxt =
'<p><img src="http://placehold.it/720x480.jpg" alt="alt text" class="tag"></p>'
it('work with markdown-it-attrs', () => {
const md = new MarkdownIt()
md.use(MarkdownItClass, mapping)
expect(md.render(mdtxt).trim()).toBe(htmltxt)
})
it('works with markdown-it-attrs', () => {
const mapping = {

@@ -56,0 +70,0 @@ h1: ['is-4', 'is-black'],

{
"name": "@toycode/markdown-it-class",
"version": "1.1.0",
"version": "1.2.0",
"description": "A markdown-it plugin that add classes by tag name",

@@ -24,3 +24,3 @@ "keywords": [

"devDependencies": {
"jest": "^23.6.0",
"jest": "^25.0.0",
"markdown-it": "^8.4.2",

@@ -27,0 +27,0 @@ "markdown-it-attrs": "^2.3.1",