npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hexo-filter-highlight

v1.0.0

Published

Highlight plugin using highlight.js for Hexo.

Downloads

37

Readme

hexo-filter-highlight

Build Status node npm downloads npm version GitHub release

Introduction

screenshot

Highlight plugin using highlight.js for Hexo. This plugin not highlight when generating, you must highlight your code in front-end.

Optionally, if you using Backtick Code Block style to insert code block, close the default highlight of hexo, your page will display unnormally, you can use this plugin to instead.

You can visit my blog to see the highlight result.

Feautre

  • Using highlight.js freely
  • Trim indent of code block
  • Code line numbering support
  • Code block copy support

Install

$ npm install hexo-filter-highlight --save

Then set enable: false to turn off the hexo highlight in _config.yml under blog.

Config

backend

config _config.yml under your blog

# hexo-filter-plugin (https://github.com/Jamling/hexo-filter-highlight) config 
## highlight in frontend, the plugin (backend) just do some prepare work.
## you need to read the docs on https://github.com/Jamling/hexo-filter-highlight to getting start
hljs:
  enable: true #true to enable the plugin
  line_number: frontend # add line_number in frontend or backend (not recommend, have bugs in special hexo version)
  trim_indent: backend # trim the indent of code block to prettify output. backend or front-end (recommend)
  copy_code: true # show copy code in caption.
  label:
    left: Code
    right: ':'
    copy: Copy Code

frontend

Import highlight js and style css in your <head></head>

<link rel="stylesheet" href="//cdn.bootcss.com/highlight.js/9.6.0/styles/github.min.css">
<script src="//cdn.bootcss.com/highlight.js/9.6.0/highlight.min.js"></script>

Then add highlight script after document loaded, such as under document.onready().

  • Simply
$(document).ready(function(){
    hljs.initHighlightingOnLoad();
});
  • Normally, insert following script after the document loaded
  var trim_indent = true;
  var line_number = true;
  // enable highlight
  $('pre code').each(function(i, block) {
    var texts = $(this).text().split('\n');
     // trim indent
     if (trim_indent){
      var tab = texts[0].match(/^\s{0,}/);
      if (tab) {
        var arr = [];
        texts.forEach(function(temp) {
          arr.push(temp.replace(tab, ''));
        });
        $(this).text(arr.join('\n'));
      }
    }
    // add line number
    if (line_number) {
      console.log("show line number in front-end");
      var lines = texts.length - 1;
      var $numbering = $('<ul/>').addClass('pre-numbering');
      $(this).addClass('has-numbering').parent().append($numbering);
      for (i = 1; i <= lines; i++) {
        $numbering.append($('<li/>').text(i));
      }
    }
    // hightlight
    hljs.highlightBlock(block);
  • Advancely

See hljs.js under Nova theme.

Last add your css to control the code block and line number. See nova.scss under Nova theme.

Refer

See My Blog for more information.

License

MIT