All Projects → arnav-kr → shikijs

arnav-kr / shikijs

Licence: Apache-2.0 license
A JavaScript Library for Syntax Highlighting with Awesome themes

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to shikijs

vaporwave-theme-vscode
AESTHETICS
Stars: ✭ 28 (+33.33%)
Mutual labels:  syntax-highlighting, themes
ctxmenu
Tiny and customizable context menu generator
Stars: ✭ 20 (-4.76%)
Mutual labels:  javascript-library, easy-to-use
Markdown Css
A tool convert css style into markdown inline style
Stars: ✭ 122 (+480.95%)
Mutual labels:  themes, easy-to-use
rehype-highlight
plugin to highlight code blocks
Stars: ✭ 127 (+504.76%)
Mutual labels:  syntax-highlighting, syntax-highlight
Enlighterjs
🔆 an open source syntax highlighter written in pure javascript
Stars: ✭ 379 (+1704.76%)
Mutual labels:  syntax-highlighting, javascript-library
Vue Prism
Simple Vue.js Syntax highlighting with Prism.js
Stars: ✭ 43 (+104.76%)
Mutual labels:  syntax-highlighting, javascript-library
Ft Syntax Highlight
Pure CSS syntax highlighter, no Javascript required. Includes built-in tooltips with UI themes and syntax highlighting themes
Stars: ✭ 42 (+100%)
Mutual labels:  syntax-highlighting, themes
Vscode Vlang
V Language extension for Visual Studio Code.
Stars: ✭ 190 (+804.76%)
Mutual labels:  syntax-highlighting, themes
nord-notepadplusplus
An arctic, north-bluish clean and elegant Notepad++ theme.
Stars: ✭ 112 (+433.33%)
Mutual labels:  syntax-highlighting
FormToolbar
Simple, movable and powerful toolbar for UITextField and UITextView.
Stars: ✭ 85 (+304.76%)
Mutual labels:  easy-to-use
jackson-js
JavaScript object serialization and deserialization library using decorators. It supports also advanced Object concepts such as polymorphism, Object identity and cyclic objects.
Stars: ✭ 86 (+309.52%)
Mutual labels:  javascript-library
ace-documentation
A free documentation theme for Hugo, powered by Bootstrap 4. Repsonsive, search, code highlighting and more.
Stars: ✭ 91 (+333.33%)
Mutual labels:  syntax-highlighting
jducers
A js transducers-like implementation using ES9
Stars: ✭ 25 (+19.05%)
Mutual labels:  javascript-library
sane-reports
Reports library that will keep you sane and not pulling your hair out
Stars: ✭ 47 (+123.81%)
Mutual labels:  javascript-library
axiom
Axiom - A Hugo Theme. GitTip: https://gitcoin.co/tip?username=jhauraw
Stars: ✭ 67 (+219.05%)
Mutual labels:  syntax-highlighting
tomloprodModal
tomloprodModal is a configurable pure javascript library to create responsive and minimalist modal windows with no dependencies.
Stars: ✭ 17 (-19.05%)
Mutual labels:  javascript-library
onli-reducer
⚛️ One line reducer. State management without boilerplate.
Stars: ✭ 31 (+47.62%)
Mutual labels:  javascript-library
nord-atom-syntax
An arctic, north-bluish clean and elegant Atom syntax theme.
Stars: ✭ 72 (+242.86%)
Mutual labels:  syntax-highlighting
intellij-firebase-highlighter
A Syntax Highlighter for Firebase Rules.
Stars: ✭ 26 (+23.81%)
Mutual labels:  syntax-highlighting
syntax highlighter
Syntax Highlighter for Dart/Flutter Code
Stars: ✭ 28 (+33.33%)
Mutual labels:  syntax-highlighting

Shikijs

A JavaScript Library for Syntax Highlighting on the way with the themes you always wanted.

Note: The library will no longer be maintained. It may or may not work!

Overview

Shiki Highlighter JS is a javascript library built on top of Shikijs. It provides more features than Shikijs. It is a Syntax Highlighting Library and Have Amazing themes. Its supports many languages for highlighting. Even the Code bits Yo're seeing in the documentation page is highlighted using Shiki Highlighter JS

Check Out Available Themes and available Languages

Including the Library

To include the library to your project, add the following script element.

<script src="https://cdn.jsdelivr.net/gh/arnav-kr/Shikijs/dist/V1.2.1/shikiHighlighter.min.js"></script>

Getting Started

By default you get the Shiki object. We can perform different actions on this object.

Methods

There are 4 different methods in Shiki object.

Shiki.getHTMLCode()

Argument Name Type Default
code String -
language String -
theme String github-dark

NOTE: The third theme argument is optional as the default theme is "github-dark"

Shiki.highlight()

highlight() comes in handy when you want to highligt code in an html element. It requires the reference of an html element as the argument, Shiki will replace it's textContent with the highlighted version of it. It also requires to have certain attributes for the element. They are

Name Type Required
data-language String true
data-theme String false

Example: HTML:

<div id="myCode" data-language="py" data-theme="nord"></div>

JS

var element = document.getElementById("myCode");
Shiki.highlight(element); //The text inside myCode div will automatically be highlighted

Shiki.highlightAll()

highlightAll() comes in handy when you want to highligt code in a selection of html elements. It doesnt require any arguments to be passed with the function, Shiki will replace all the elements with the class shiki-target and replaces textContent with the highlighted version of it. It also requires to have certain attributes for the all elements with the specific class. They are

Name Type Required
data-language String true
data-theme String false

Example:

HTML:

<div class="shiki-target" data-language="py" data-theme="nord"></div>
<div class="shiki-target" data-language="js" data-theme="github-dark"></div>
<div class="shiki-target" data-language="c" data-theme="github-light"></div>

JS

Shiki.highlightAll();

Shiki.setTheme()

setTheme() allows you to change the default theme. It takes the name of the theme as argument and sets it as the default theme for the session.

Shiki.setTheme("github-light");

Shiki.getHTMLCode("function start(){}", "javascript");
//The code returned would be highlighted in github-light

Properties

Shiki.themes

themes returns an array of all available themes you can use.

JS

console.log(Shiki.themes);

Shiki.languages

languages returns an array of all available languages you can use.

JS

console.log(Shiki.languages);

Shiki.errorLog

errorLog is an Array in which you can find all the errors that Shiki ran into when it was running or while it was highlighting your code. Every element of this array is an object. The object structure is as follows.

{
  error:"ERROR_NAME",
  time:"ERROR_TIMESTAMP"
}

At a Glance

By default you get the Shiki object. You can perform the below actions with it.

Methods

Name Arguments Argument Types Return Type
Shiki.getHTMLCode() Code, Language, Theme(optional) String, String, String Promise
Shiki.highlight() HTML Element HTMLElement null
Shiki.highlightAll()
Shiki.setTheme() Theme String

Properties

Name Type
Shiki.themes Array
Shiki.languages Array
Shiki.errorLog Array

Shiki Highlighter JS by Arnav Kumar.

Having Trouble reading the documentation? view it Online

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