1. highlight.js-async-webpack
webpack async for highlight.js
highlight.js-async-webpack
Package: highlight.js-async-webpack
Created by: CHENXCHEN
Last modified: Sat, 18 Jun 2022 20:43:58 GMT
Version: 1.0.4
License: MIT
Downloads: 4,067
Repository: https://github.com/CHENXCHEN/highlight.js-async-webpack

Install

npm install highlight.js-async-webpack
yarn add highlight.js-async-webpack

highlight.js-async-webpack

async language request from highlight.js

Install

 npm install highlight.js-async-webpack

Usage

 import hljs from 'highlight.js-async-webpack'
hljs.hljsBlock(dom, lang, function(){
// do something...
});

Example

 function highLightCodex(str, callback) {
    var dom = document.createElement('div');
    dom.innerHTML = str;
    var pre_code = dom.querySelectorAll('pre.hljs > code');
    if (pre_code) {
        var cnt = 0;
        var deal = 0;
        for (var i = 0; i < pre_code.length; i++) {
            if (pre_code[i].className.length > 0) {
                cnt = cnt + 1;
                hljs.hljsBlock(pre_code[i], pre_code[i].className, function() {
                    deal = deal + 1;
                    if (deal == cnt) {
                        callback(dom.innerHTML);
                    }
                });
            }
        }
    }
}

Version

  • 1.0.4 If highlight error return false.
  • 1.0.3 Add async files list(file.lang.hljs.js).
  • 1.0.2 Add callback function

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin