You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
414 B

  1. const hljs = require('highlight.js')
  2. module.exports = {
  3. async init($, config) {
  4. $('pre > code').each((idx, elm) => {
  5. const codeClasses = $(elm).attr('class') || ''
  6. if (codeClasses.indexOf('language-') < 0) {
  7. const result = hljs.highlightAuto($(elm).text())
  8. $(elm).addClass('language-', result.language)
  9. }
  10. $(elm).parent().addClass('prismjs line-numbers')
  11. })
  12. }
  13. }