This program is a simple syntax highlighter written in Rust using the Syntect library. It reads the contents of a file and performs syntax highlighting based on the file's extension. The highlighted contents are then printed to the console.
To use the syntax highlighter, follow these steps:
-
Make sure you have Rust installed on your system. If not, you can download and install it from the official Rust website: https://rust-lang.org
-
Clone or download the source code of this program.
-
Open a terminal and navigate to the directory containing the source code.
-
Build the program by running the following command:
$ cargo build --release
$ mv target/release/catc /usr/local/bin/
- After a successful build, you can run the program with the following command:
$ catc <filename>
Replace <filename>
with the path to the file you want to highlight.
- The program will read the contents of the file, perform syntax highlighting, and print the highlighted contents to the console.
Here are a few examples of how to use the syntax highlighter:
- Highlight a HTML file:
$ catc test.html
- Highlight a Rust file:
$ catc src/main.rs
-
If no file extension is provided or the file extension is not recognized, the program will default to using the "txt" extension for highlighting.
-
The program uses the "base16-ocean.dark" theme for syntax highlighting. If you want to use a different theme, you can modify the
output
function in the code and replace"base16-ocean.dark"
with the name of the desired theme.
That's it! You can now use this syntax highlighter to quickly visualize the syntax of various programming and markup languages. Feel free to modify and customize the program according to your needs.