Vue Highlight.js
Highlight.js syntax highlighter component for Vue.
⚙️ Installation
Via npm:
Or Yarn:
For TypeScript, Please install @types/highlight.js
.
? Usage
Main file:
There are 2 ways to import Highlight.js languages.
-
Import only languages that you want.
-
Import all languages.
Vue file:
⛕ Plugin Options
languages
Type: { [name: string]: HLJSLang }
Default: {}
Highlight.js languages.
Add the languages that you want to use here.
name
is the name of language to register with Highlight.js' registerLanguage(name, language)
API.
See https://github.com/isagalaev/highlight.js#commonjs about importing each language from highlight.js.
? API
<highlight-code>
Highlight.js code block.
? Slots
Static code content.
? Properties
lang
Type: String
Highlight.js language.
inline
Type: Boolean
Default: false
Enable inline code block when set it to true
.
code
Type: String
Code content in code block.
You can use this prop if you want to bind code content to your data source.
It's useful for dynamic code content.
Component will ignore slot
static content if you use this.
auto
Type: Boolean
Enable auto detecting code language.
Code will be detected by highlight.js'
highlightAuto
function.
auto
will work well when you import all Highlight.js languages.
Component will ignore lang
prop if you use auto
.