Skip to content

Commit

Permalink
feat: add shiki/prismjs class names to differentiate highlight pl…
Browse files Browse the repository at this point in the history
…ugins (#181)

Co-authored-by: Mister-Hope <[email protected]>
  • Loading branch information
pengzhanbo and Mister-Hope authored May 30, 2024
1 parent 3c4159b commit 0ef4c98
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ export const highlightPlugin = (
notationHighlight(parser)
}

/**
* Add the `prismjs` class name to distinguish the highlight library used for the current code block.
*/
parser.pre.classList.push('prismjs')

parser.pre.classList.push(languageClass)

return parser.stringify()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export const preWrapperPlugin = (
// resolve title from token info
const title = resolveAttr(info, 'title') ?? language.ext

return `<div class="${languageClass}" data-ext="${language.ext}" data-title="${title}">${result}</div>`
/**
* Add information to dataset for current code block.
*/
return `<div class="${languageClass}" data-highlighter="prismjs" data-ext="${language.ext}" data-title="${title}">${result}</div>`
}
}
Loading

0 comments on commit 0ef4c98

Please sign in to comment.