Socket
Socket
Sign inDemoInstall

markdown-it-highlightjs

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-highlightjs - npm Package Compare versions

Comparing version 4.1.0 to 4.2.0

8

CHANGELOG.md

@@ -7,2 +7,5 @@ # [Changelog](http://keepachangelog.com/)

## [4.2.0] - 2024-09-18
* Support multiple `<code>` tags in the same `<pre>`. ([#33], [#34])
## [4.1.0] - 2024-05-16

@@ -72,3 +75,4 @@ * Upgrade highlight.js to 11.9.0. ([#29])

[Unreleased]: https://github.com/valeriangalliat/markdown-it-highlightjs/compare/v4.1.0...HEAD
[Unreleased]: https://github.com/valeriangalliat/markdown-it-highlightjs/compare/v4.2.0...HEAD
[4.2.0]: https://github.com/valeriangalliat/markdown-it-highlightjs/compare/v4.1.0...v4.2.0
[4.1.0]: https://github.com/valeriangalliat/markdown-it-highlightjs/compare/v4.0.1...v4.1.0

@@ -105,1 +109,3 @@ [4.0.1]: https://github.com/valeriangalliat/markdown-it-highlightjs/compare/v4.0.0...v4.0.1

[#29]: https://github.com/valeriangalliat/markdown-it-highlightjs/pull/29
[#33]: https://github.com/valeriangalliat/markdown-it-highlightjs/issues/33
[#34]: https://github.com/valeriangalliat/markdown-it-highlightjs/pull/34

2

dist/core.js

@@ -64,3 +64,3 @@ var __defProp = Object.defineProperty;

return function wrappedRenderer(...args) {
return renderer(...args).replace('<code class="', '<code class="hljs ').replace("<code>", '<code class="hljs">');
return renderer(...args).replace(/<code class="/g, '<code class="hljs ').replace(/<code>/g, '<code class="hljs">');
};

@@ -67,0 +67,0 @@ }

{
"name": "markdown-it-highlightjs",
"version": "4.1.0",
"version": "4.2.0",
"description": "Preset to use highlight.js with markdown-it.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -74,4 +74,4 @@ import MarkdownIt from 'markdown-it'

return renderer(...args)
.replace('<code class="', '<code class="hljs ')
.replace('<code>', '<code class="hljs">')
.replace(/<code class="/g, '<code class="hljs ')
.replace(/<code>/g, '<code class="hljs">')
}

@@ -78,0 +78,0 @@ }

@@ -134,2 +134,22 @@ /* eslint-env mocha */

})
it('applies hljs class to all code tags', () => {
// Define a mock plugin that handles the 'multicode' language
const multicodeHlJsPlugin = (md) => {
const oldHighlight = md.options.highlight
md.options.highlight = (code, lang, attrs) => {
if (lang && lang === 'multicode') {
return '<pre><code class="language-multicode">A</code><code class="language-multicode-overlay">B</code></pre>'
}
return oldHighlight(code, lang, attrs)
}
}
const markdownIt = md()
markdownIt.use(highlightjs)
markdownIt.use(multicodeHlJsPlugin)
assert.equal(markdownIt.render('```multicode\n```'), '<pre><code class="hljs language-multicode">A</code><code class="hljs language-multicode-overlay">B</code></pre>\n')
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc