#syntax-highlighter #language #style #foo #file #html #write

app k-lighter

K-lighter is a syntax highlighter for K language

5 stable releases

1.0.4 Sep 4, 2023
1.0.3 Aug 20, 2023

#52 in Text editors

Download history 2/week @ 2024-02-25 68/week @ 2024-03-31

68 downloads per month

MIT license

22KB
382 lines

K-lighter

K-lighter is a syntax highlighter for K language.

Installation

Use cargo to install this package:

cargo install k-lighter

You can also build this package from source. Clone this repo using the following command:

git clone https://github.com/ondrachwiedziuk/k-lighter.git

Then enter main directory and run:

cargo install --path .

To have better performance, you can write alias in your .bashrc file:

alias k-lighter="$HOME/.cargo/bin/k-lighter"

Usage

To use k-lighter, write:

k-lighter [OPTIONS] <INPUT> <OUTPUT>

Arguments

Name Description
INPUT Path to your K script.
OUTPUT Path to HTML file where highlighted code will be located.

Options

Short Long Description
-s --style Style which is used [default: basic]
-h --help Print help
-V --version Print version

Example

To highlight file foo.k, write:

k-lighter foo.k foo.html

Custom styles

You can also customize styles. Just append your pattern to the end of $HOME/.cargo/k-lighter.ini file. Patterns have the following structure:

[NAME]
numbers = HEX_COLOR
vars = HEX_COLOR
verbs = HEX_COLOR
adverbs = HEX_COLOR
reserved = HEX_COLOR
pars_0 = HEX_COLOR
pars_1 = HEX_COLOR
pars_2 = HEX_COLOR
pars_3 = HEX_COLOR
comments = HEX_COLOR
string = HEX_COLOR
background = HEX_COLOR

Default style is basic:

[basic]
numbers = ffffff
vars = ffff00
verbs = 00ffff
adverbs = ff00ff
reserved = ff0000
pars_0 = 006600
pars_1 = 009900
pars_2 = 00cc00
pars_3 = 00ff00
comments = 0000ff
string = 508050
background = 000000

Conclusion

This project is supposed to be used inside text editors. However, this project is written in Rust, so it requires some JavaScript to wrap this core and make it work with text editors like VS Code.

Another direction of this project can be some smarter features like recognizing unused variables, formatting a code by some template and checking correct syntax of K.

Dependencies

~1–11MB
~94K SLoC