https://github.com/alexius-huang/leichterjs
Simple Code Highlighting Tool Named by Lighter in German
https://github.com/alexius-huang/leichterjs
Last synced: 2 months ago
JSON representation
Simple Code Highlighting Tool Named by Lighter in German
- Host: GitHub
- URL: https://github.com/alexius-huang/leichterjs
- Owner: Alexius-Huang
- Created: 2017-09-06T16:27:41.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-23T15:36:32.000Z (over 7 years ago)
- Last Synced: 2025-02-12T05:56:20.650Z (4 months ago)
- Language: JavaScript
- Size: 189 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LeichterJS
[](https://travis-ci.org/Maxwell-Alexius/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](https://github.com/Maxwell-Alexius/LeichterJS/tree/master/sample)!
Assume you have a simple python code in a `pre` tag, which is shown below:
```html
s = 0
for i in range(10):
s += i
print(i) # => 45def addition(a, b)
return a + bage = 18
if 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:
```js
var lighter = new Leichter({
lang: 'python',
element: 'python-code'
})
```And then ignite it!
```js
lighter.ignite(); // Or you can use lighter.entzünden() which is the alias method of the ignite method
```There you go:
