LeichterJS
Simple Code Highlighting Tool Named by Lighter in German
Installation
Using Yarn:
$ yarn add leichter
Status
Currently only support most of the general Python syntax highlighting
Usage
Checkout the samples here!
Assume you have a simple python code in a pre
tag, which is shown below:
s = 0for i in range(10): s += iprint(i) # => 45 def addition(a, b) return a + b age = 18if age <= 18: print("Young")elif age <= 60: print("Adult")else: print("Old Man")# => "Young" class Dog(Animal): def __init__(self, name): self.name = name self.tricks = [] def addTrick(trick) self.tricks.append(trick)
In JavaScript, specify the language you wanted to highlight and the ID of the element to highlight the code:
var lighter = lang: 'python' element: 'python-code'
And then ignite it!
lighter; // Or you can use lighter.entzünden() which is the alias method of the ignite method
There you go: