@toycode/markdown-it-class
Advanced tools
Comparing version
@@ -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 = '' | ||
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", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
8045
32.02%8
14.29%101
12.22%1
Infinity%