1. vue-hljs
Highlight.js plugin for Vue.js 3.0
vue-hljs
Package: vue-hljs
Created by: sunskyxh
Last modified: Wed, 12 Apr 2023 05:58:09 GMT
Version: 3.0.1
License: BSD-3
Downloads: 4,333
Repository: https://github.com/sunskyxh/vue-hljs

Install

npm install vue-hljs
yarn add vue-hljs

npm package
build status

vue-hljs

Overview

ℹ️ Update: Highlight.js has released an official vue plugin since Mar 23, 2021. See highlightjs/vue-plugin.

This is a vue plugin which allows you to highlight code blocks via vue-directive.

Install

 npm install vue-hljs highlight.js

or

 yarn add vue-hljs highlight.js

Example

 import { createApp } from 'vue'
import vueHljs from "vue-hljs";
import hljs from "highlight.js";
//if you want to use default color, import this css file
import "vue-hljs/dist/style.css";

const app = createApp({})
app.use(vueHljs, { hljs })
 <div v-highlight>
  <pre>
    <!-- you can specify language by modifing the class attribute -->
    <code class="typescript">...</code>
  </pre>
</div>

Use your own style

This plugin use gruvbox-dark as default style.

You can wirte your own style or see highlight.js demo.
And then import your css file in Vue project entry.

Other similar project

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