https://github.com/hanrodz/syntax-highlighter
Highlight syntax in C++, Python and JavaScript code (common lexical categories only)
https://github.com/hanrodz/syntax-highlighter
c lex lexer python syntax-highlighting
Last synced: 2 months ago
JSON representation
Highlight syntax in C++, Python and JavaScript code (common lexical categories only)
- Host: GitHub
- URL: https://github.com/hanrodz/syntax-highlighter
- Owner: hanrodz
- Created: 2022-03-31T01:39:31.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-06-06T23:22:24.000Z (about 4 years ago)
- Last Synced: 2025-07-08T14:43:16.786Z (12 months ago)
- Topics: c, lex, lexer, python, syntax-highlighting
- Language: C
- Homepage:
- Size: 25.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Syntax Highlighter
The program receives a text file containing code in C++, Python or JavaScript and outputs an HTML file containing the same code and highlighting elements from lexical categories that are shared between the three languages.
**Note: multi-threaded highlighting can be run in the [Python](python) implementation**
## How to highlight code
From the folder where all files are stored, run shell script with path to code file as an argument:
./run.sh path/to/file.py
In computers that cannot run shell scripts the code can be manually compiled and run:
gcc scanner.c lex.yy.c -o scanner
./scanner < path/to/file.cpp
The highlighted code will be stored in ```output.html```, using the stylesheet ```style.css``` contained in this folder.
## Important notes
- An exception is yet to be implemented so that C++ and JavaScript comments be told apart from Python integer divisions ("//").
- Another exception is yet to be implemented so that Python comments be highlighted if there is no space between "#" and the text. C++ "#" statements should be taken into consideration.
## Sources consulted
[https://youtu.be/54bo1qaHAfk](https://youtu.be/54bo1qaHAfk)