1. vue-highlightjs
Syntax highlighting with highlight.js for Vue.js 2.x
vue-highlightjs
Package: vue-highlightjs
Created by: metachris
Last modified: Tue, 28 Jun 2022 19:37:25 GMT
Version: 1.3.3
License: MIT
Downloads: 34,488
Repository: https://github.com/metachris/vue-highlightjs

Install

npm install vue-highlightjs
yarn add vue-highlightjs

vue-highlightjs

Vue.js syntax highlighting made easy, using highlight.js.

Build Status

Quickstart

Installation

npm install --save vue-highlightjs

Using vue-highlightjs

In your main JavaScript file (eg. main.js):

 // Import Vue and vue-highlgihtjs
import Vue from 'vue'
import VueHighlightJS from 'vue-highlightjs'

// Tell Vue.js to use vue-highlightjs
Vue.use(VueHighlightJS)

In your template, in order to highlight javascript code:

 <!-- If your source-code lives in a variable called 'sourcecode' -->
<pre v-highlightjs="sourcecode"><code class="javascript"></code></pre>

<!-- If you want to highlight hardcoded source-code -->
<pre v-highlightjs><code class="javascript">const s = new Date().toString()</code></pre>

  • You can see a live example here: https://www.python-boilerplate.com/
  • Fiddle with it: https://jsfiddle.net/metachris/1vz9oobc/
  • See also this blog post for more information: https://www.metachris.com/2017/02/vuejs-syntax-highlighting-with-highlightjs/

Contributing

Any sort of contributions and feedback is much appreciated. Just
leave an issue or pull-request!

This project uses the AirBnB code style.

Please run npm run lint and npm run test before you submit a pull request! <3

About

Author: Chris Hager [email protected] (https://www.metachris.com)

License: MIT

Contributors:

Changelog

v1.3.3

  • Documentation

v1.3.1

  • Changed const to var for compatibility with PhantomJS and UglifyJS
  • Bugfix to allow empty content

v1.2.2

  • Fixed displaying and highlighting HTML tags passed as value to the directive (thanks @nguyenvanduocit)

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code