🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

vue-code-highlighter

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-code-highlighter

Vue component for highlighting code or syntax with modern style, copy functionality, multicode and powered by Highlight.js

1.1.3
latest
Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created

Vue Code Highlighter

NPM Downloads License

Vue component for highlighting code or syntax with modern style, copy functionality, multicode and powered by Highlight.js

Installation

npm install vue-code-highlighter highlight.js

// or use yarn
yarn add vue-code-highlighter highlight.js

Usage

Importing

This package support either composition and options api with typescript or javascript.

import { VueCodeHighlighter, VueCodeHighlighterMulti } from 'vue-code-highlighter';
import 'vue-code-highlighter/dist/style.css'

This package does not need to call CSS from the highlight.js package because I have already wrapped it. What you need to do is install the highlight.js package.

Example & Demo

Example code and demo available in ichsanputr.github.io/vue-code-highlighter

Props

There are 2 types of components, namely VueCodeHighlighter and VueCodeHighlighterMulti, both of them have different props.

VueCodeHighlighter

AttributeTypeIs RequiredDescription
langStringtrueCode languange from Highlighter cheatset, see Supported languange
codeStringtruePlain code which will be displayed, please wrap your code using backtick (``)
titleStringnoCustom title in header
disableCopyBooleannoDisable copy button and copy functionality to code

VueCodeHighlighterMulti

AttributeTypeIs RequiredDescription
codeArraytrueSee example below
disableCopyBooleannoDisable copy button and copy functionality to code

Example for lang props in Multi Code.

const codeMulti = [
  {
    lang: "js",
    title: "vue",
    code: codeVue.value
  },
  {
    lang: "html",
    code: codeHtml.value,
    title: 'html'
  },
  {
    lang: "css",
    code: codeCss.value,
  },
]

FAQs

Package last updated on 03 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts