All Projects → highlightjs → vue-plugin

highlightjs / vue-plugin

Licence: BSD-3-Clause license
Highlight.js Vue Plugin

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to vue-plugin

vue-inview
vue-plugin for in-view package
Stars: ✭ 100 (-1.96%)
Mutual labels:  vue-plugin
vue-bus
Tiny simple central event bus plugin for Vue.js
Stars: ✭ 50 (-50.98%)
Mutual labels:  vue-plugin
react-tagify
📛 Powerful Pure React Component For Hashtags and Mentions In Your React App
Stars: ✭ 24 (-76.47%)
Mutual labels:  highlight
DyAnnotationExtractor
DyAnnotationExtractor is software for extracting annotations (highlighted text and comments) from e-documents like PDF.
Stars: ✭ 34 (-66.67%)
Mutual labels:  highlight
ng-walkthrough
A walkthrough for Angular
Stars: ✭ 21 (-79.41%)
Mutual labels:  highlight
Sketch-Highlighter
Sketch plugin that generates highlights for selected text layers
Stars: ✭ 41 (-59.8%)
Mutual labels:  highlight
Euro2016 TerminalApp
⚽ Instantly find 🏆EURO 2016 live-streams & highlights, now a Web App!
Stars: ✭ 54 (-47.06%)
Mutual labels:  highlight
geshi-1.1
Next generation of Generic Syntax Highlighter for PHP
Stars: ✭ 70 (-31.37%)
Mutual labels:  highlight
generator-vue-plugin
Yeoman generator generating vue plugin 🚀
Stars: ✭ 29 (-71.57%)
Mutual labels:  vue-plugin
reveal-code-focus
A Reveal.js plugin that allows focusing on specific lines of code blocks.
Stars: ✭ 108 (+5.88%)
Mutual labels:  highlight
piu.clj
Simple pastebin
Stars: ✭ 14 (-86.27%)
Mutual labels:  highlight
vue-ray
Debug your Vue 2 & 3 code with Ray to fix problems faster
Stars: ✭ 48 (-52.94%)
Mutual labels:  vue-plugin
vue-img-orientation-changer
A vue plugin that can help you display image in correct orientation.
Stars: ✭ 38 (-62.75%)
Mutual labels:  vue-plugin
colocat
Fegeya Colocat, Colorized 'cat' implementation. Written in C++17.
Stars: ✭ 14 (-86.27%)
Mutual labels:  highlight
datatables.mark.js
A DataTables plugin for mark.js to highlight search terms in tables
Stars: ✭ 44 (-56.86%)
Mutual labels:  highlight
vue-jss-plugin
JSS plugin implementation for Vue.js
Stars: ✭ 24 (-76.47%)
Mutual labels:  vue-plugin
v-dropdown-menu
Dropdown menu plugin for vuejs, supported ssr.
Stars: ✭ 23 (-77.45%)
Mutual labels:  vue-plugin
vue-package-template
Boilerplate for your next, ES6 Vue.js package. Ready for npm deployments
Stars: ✭ 12 (-88.24%)
Mutual labels:  vue-plugin
Highlightr-Plugin
A minimal and aesthetically pleasing highlighting menu that makes color-coded highlighting much easier 🎨.
Stars: ✭ 321 (+214.71%)
Mutual labels:  highlight
vue-plausible
Plausible Analytics Vue.js Plugin and NuxtJS Module
Stars: ✭ 107 (+4.9%)
Mutual labels:  vue-plugin

Highlight.js plugin for Vue.js

latest version latest version vue 3 vue 2 license

publish size gzipped size slack

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. Version 1.x.x is compatible with Vue.js v2; version 2.x.x with Vue.js v3.

Using the pre-built libraries

<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)

Using ES6 modules / bundling

import 'highlight.js/styles/stackoverflow-light.css'
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 'highlight.js/styles/stackoverflow-light.css'
import 'highlight.js/lib/common';
import hljsVuePlugin from "@highlightjs/vue-plugin";

const app = createApp(App)
app.use(hljsVuePlugin)
app.mount('#app')

Note that the highlight.js/lib/common import does not import the hljs object because it registers common languages internally and modern web bundlers like webpack will optimize out unused imported names. If you want to customize the hljs object, you can import it like the previous example.

Using component locally

<template>
    <highlightjs
        language="js"
        code="console.log('Hello World');"
    />
</template>

<script>
import 'highlight.js/lib/common';
import hljsVuePlugin from "@highlightjs/vue-plugin";

export default {
    components: {
        highlightjs: hljsVuePlugin.component
    }
}
</script>

Building the pre-built library from source

We use rollup to build the dist distributable.

npm run build
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].