All Projects â†’ gluons â†’ Vue Highlight.js

gluons / Vue Highlight.js

Licence: mit
📜 Highlight.js syntax highlighter component for Vue.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Vue Highlight.js

Lowlight
Virtual syntax highlighting for virtual DOMs and non-HTML things
Stars: ✭ 310 (+72.22%)
Mutual labels:  highlight, syntax
Vue Gh Corners
GitHub Corners for Vue.
Stars: ✭ 30 (-83.33%)
Mutual labels:  hacktoberfest, vue-component
Highlightjs Line Numbers.js
Line numbering plugin for Highlight.js
Stars: ✭ 323 (+79.44%)
Mutual labels:  hacktoberfest, highlight
see-cli
A colorful 🌈 cat - syntax highlight print CLI
Stars: ✭ 24 (-86.67%)
Mutual labels:  syntax, highlight
Vue Morphling
Vue filters and directives collection.
Stars: ✭ 179 (-0.56%)
Mutual labels:  hacktoberfest, highlight
remark-highlight.js
Legacy plugin to highlight code blocks with highlight.js — please use `rehype-highlight` instead
Stars: ✭ 58 (-67.78%)
Mutual labels:  syntax, highlight
Python
Python cheatsheet
Stars: ✭ 25 (-86.11%)
Mutual labels:  hacktoberfest, syntax
Pdfvuer
A PDF viewer for Vue using Mozilla's PDF.js
Stars: ✭ 443 (+146.11%)
Mutual labels:  hacktoberfest, vue-component
Vue Social Sharing
A renderless Vue.js component for sharing links to social networks, compatible with SSR
Stars: ✭ 1,071 (+495%)
Mutual labels:  hacktoberfest, vue-component
Yii2 Quill
Yii 2 implementation of Quill, modern WYSIWYG editor
Stars: ✭ 52 (-71.11%)
Mutual labels:  hacktoberfest, highlight
CodeEditorView
Code Editor UITextView
Stars: ✭ 20 (-88.89%)
Mutual labels:  syntax, highlight
Vue Gmaps
Search places and address using Google Maps API
Stars: ✭ 108 (-40%)
Mutual labels:  hacktoberfest, vue-component
colocat
Fegeya Colocat, Colorized 'cat' implementation. Written in C++17.
Stars: ✭ 14 (-92.22%)
Mutual labels:  syntax, highlight
Refractor
Lightweight, robust, elegant virtual syntax highlighting using Prism
Stars: ✭ 291 (+61.67%)
Mutual labels:  highlight, syntax
Nord Highlightjs
An arctic, north-bluish clean and elegant highlight.js theme.
Stars: ✭ 49 (-72.78%)
Mutual labels:  highlight, syntax
Elm Syntax Highlight
Syntax highlighting in Elm
Stars: ✭ 61 (-66.11%)
Mutual labels:  highlight, syntax
Geshi 1.0
Original version of Generic Syntax Highlighter for PHP
Stars: ✭ 149 (-17.22%)
Mutual labels:  hacktoberfest, highlight
Pinpog
Ping-Pong-like game in Assembly that works without OS
Stars: ✭ 177 (-1.67%)
Mutual labels:  hacktoberfest
Lfs
A thing to get information on your mounted disks
Stars: ✭ 178 (-1.11%)
Mutual labels:  hacktoberfest
Capa Rules
Standard collection of rules for capa: the tool for enumerating the capabilities of programs
Stars: ✭ 178 (-1.11%)
Mutual labels:  hacktoberfest

Vue Highlight.js

license vue 2 npm npm Travis Codacy grade TSLint


💡 Version 4 with Highlight.js v10 support is under development. See version-4 branch.


📜 Highlight.js syntax highlighter component for Vue.

⚙ī¸ Installation

Via npm:

npm

npm install highlight.js vue-highlight.js

Or Yarn:

yarn add highlight.js vue-highlight.js

For TypeScript, Please install @types/highlight.js.

npm install --save-dev @types/highlight.js
# or
yarn add --dev @types/highlight.js

đŸŽŦ Demo

Go to https://gluons.github.io/vue-highlight.js

🛂 Usage

Main file:

There are 2 ways to import Highlight.js languages.

  1. Import only languages that you want.

    import Vue from 'vue';
    import VueHighlightJS from 'vue-highlight.js';
    
    // Highlight.js languages (Only required languages)
    import css from 'highlight.js/lib/languages/css';
    import javascript from 'highlight.js/lib/languages/javascript';
    import vue from 'vue-highlight.js/lib/languages/vue';
    
    /*
    * Import Highlight.js theme
    * Find more: https://highlightjs.org/static/demo/
    */
    import 'highlight.js/styles/default.css';
    
    import App from './App';
    
    /*
    * Use Vue Highlight.js
    */
    Vue.use(VueHighlightJS, {
    	// Register only languages that you want
    	languages: {
    		css,
    		javascript,
    		vue
    	}
    });
    
    new Vue({
    	el: '#app',
    	render: h => h(App)
    });
    
  2. Import all languages.

    import Vue from 'vue';
    import VueHighlightJS from 'vue-highlight.js';
    
    // Highlight.js languages (All languages)
    import 'vue-highlight.js/lib/allLanguages'
    
    /*
    * Import Highlight.js theme
    * Find more: https://highlightjs.org/static/demo/
    */
    import 'highlight.js/styles/default.css';
    
    import App from './App';
    
    /*
    * Use Vue Highlight.js
    */
    Vue.use(VueHighlightJS);
    
    new Vue({
    	el: '#app',
    	render: h => h(App)
    });
    

Vue file:

<template>
	<div id="app">
		<!-- Code Block -->
		<highlight-code lang="javascript">
			let str = 'Hello, World!';
			console.log(str);
		</highlight-code>

		<!-- Inline Code Block -->
		<highlight-code lang="javascript" inline>alert('Hello, World!');</highlight-code>
	</div>
</template>

<script>
// JavaScript...
</script>

<style>
/* StyleSheet... */
</style>

⛕ 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.

❓ FAQ

  • How to write HTML code inside slot?

    You have to escape all HTML tags before add it into slot.
    If you didn't do that, browser will interpret those tags as HTML element.
    ℹī¸ See isagalaev/highlight.js#866

    If you use code property instead of slot, you don't need to worry about this.
    Vue Highlight.js will automatically escape it for you.

  • Why did I get SyntaxError: Unterminated template literal error when used <script></script> in code property?

    If you add </script> at anywhere inside script tag, although it's a string inside quotes, it will always close the script tag.
    ℹī¸ See "Unterminated template literal" syntax error when literal contains script tag

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].