diff --git a/src/core.ts b/src/core.ts index 3f324fa..1f074b8 100644 --- a/src/core.ts +++ b/src/core.ts @@ -71,8 +71,8 @@ function highlightAuto (md: MarkdownIt, hljs: HLJSApi, ignoreIllegals: boolean, function wrapCodeRenderer (renderer: Renderer.RenderRule): Renderer.RenderRule { return function wrappedRenderer (...args) { return renderer(...args) - .replace('', '') + .replace(//g, '') } } diff --git a/test/test.js b/test/test.js index 6d85c99..a6226ac 100644 --- a/test/test.js +++ b/test/test.js @@ -131,4 +131,24 @@ describe('markdown-it-highlightjs', () => { md().use(highlightjs, { inline: true }).use(attrs).renderInline('`console.log(42)`{.js}'), 'console.log(42)') }) + + 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 '
AB
' + } + + return oldHighlight(code, lang, attrs) + } + } + + const markdownIt = md() + markdownIt.use(highlightjs) + markdownIt.use(multicodeHlJsPlugin) + + assert.equal(markdownIt.render('```multicode\n```'), '
AB
\n') + }) })