
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
@highlightjs/vue-plugin
Advanced tools
This plugin provides a highlightjs
component for use in your Vue.js 3 applications:
<div id="app">
<!-- bind to a data property named `code` -->
<highlightjs autodetect :code="code" />
<!-- or literal code works as well -->
<highlightjs language='javascript' code="var x = 5;" />
</div>
Note: For Vue.js version 2 support see the 1-stable branch here on GitHub. The latest
tag via NPM is compatible with Vue.js v2; the next
tag Vue.js v3.
<link rel="stylesheet" href="/path/to/styles/default.css">
<script src="/path/to/highlight.min.js"></script>
<script src="/path/to/highlight-vue.min.js"></script>
Then simply register the plugin with Vue:
const app = createApp(App)
app.use(hljsVuePlugin)
import hljs from 'highlight.js/lib/core';
import javascript from 'highlight.js/lib/languages/javascript';
import hljsVuePlugin from "@highlightjs/vue-plugin";
hljs.registerLanguage('javascript', javascript);
const app = createApp(App)
app.use(hljsVuePlugin)
app.mount('#app')
Note: The plugin imports highlight.js/lib/core
internally (but no languages). Thanks to the magic of ES6 modules you can import Highlight.js anywhere to register languages or configure the library. Any import of Highlight.js refers to the same singleton instance of the library, so configuring the library anywhere configures it everywhere.
You can also simply load all "common" languages at once (as of v11):
import hljs from 'highlight.js/lib/common';
import hljsVuePlugin from "@highlightjs/vue-plugin";
const app = createApp(App)
app.use(hljsVuePlugin)
app.mount('#app')
<template>
<highlightjs
language="js"
code="console.log('Hello World');"
/>
</template>
<script>
import hljs from 'highlight.js/lib/common';
import hljsVuePlugin from "@highlightjs/vue-plugin";
export default {
components: {
highlightjs: hljsVuePlugin.component
}
}
</script>
We use rollup to build the dist
distributable.
npm run build
FAQs
Highlight.js Vue Plugin
The npm package @highlightjs/vue-plugin receives a total of 25,669 weekly downloads. As such, @highlightjs/vue-plugin popularity was classified as popular.
We found that @highlightjs/vue-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.