node package manager

hexo-tag-vimhighlight

Highlight code using vim in hexo

Introduction

This is a hexo tag plugin which allows you to use vim syntax highlight to highlight code inside markdown.

Hexo is a static blogging system written in Node.js, it uses highlight.js by default to render code. But lots of languages are not supported by highlight.js (but always supported by vim with proper plugins). In that case, you can use this instead.

Installation

You need to have vim properly installed and configured, since this program will directly call vim.

To install, run the following command in the root directory of hexo:

npm install hexo-tag-vimhighlight --save

And add this plugin in your _config.yml.

Usage

Specify the code filetype, and whether to use line number in your markdown source file, in the common format of tag plugins:

{% vimhl vim true %}
if ! has("gui_running")                " fix alt key under terminal
	for i in range(48, 57) + range(65, 90) + range(97, 122)
		exec "set <A-" . nr2char(i) . ">=" . nr2char(i)
	endfor
endif
{% endvimhl %}

By default, line number will not be displayed, you can use {% vimhl vim %} for short.

It runs vim to highlight the code, so site-generation will probably take much longer at the first time. But then the highlighted code will be cached in your_hexo_root/data/vimHighlight.