highlight.js-async-webpack
webpack async for highlight.js
Last updated 8 years ago by chenxchen .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install highlight.js-async-webpack 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.4                                ...           latest (8 years ago)

5 Versions

  • 1.0.4                                ...           8 years ago
  • 1.0.3                                ...           8 years ago
  • 1.0.2-beta                                ...           8 years ago
  • 1.0.2                                ...           8 years ago
  • 1.0.1                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 5
Last Day 0
Last Week 5
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |