A simple syntax highlighter in Common Lisp based on a lexer and a parser.
Version 1.0 approaching!
- higlighting code in html spans
- themable with css
- string and file highlighting
- highlight code in markdown blocks
- simple and flexible highlighting engine
- based on a lexer (graylex) and a parser (cl-yacc)
- Common Lisp
I will probably support more languages in the future, but you can also define your own language styles. Also, patches to get your language style included are welcome.
Lowlight is already available in Quicklisp, but at the time of writing this you will find an old version there. If you want the latest version lowlight, please download the source and load it via ASDF (or as a local Quicklisp project), or make sure. You know, that the Quicklisp version has been updated to the current version, if it defines a package
All lowlight functions and macros live in the package
To highlight a string use
(light :common-lisp ":bla") ;=> "<span class=\"keyword\">:bla</span>"
If you want to highlight a whole file, use
(light-file :common-lisp "~/lowlight.lisp" :css "github-colors.css")
Known Bugs an Limitations
As lowlight uses graylex for lexing, it currently suffers from a bug related do the buffer size graylex uses. If you experience Problems with the lexer not correctly recognizing tokens that cross the 1024 or 2048 character border, try to increase the buffer size
The grammars that are created by
define-cfg-style are ambiguous by design, so conflict warnings will be ignored by default. If you run into problems, please consider using
define-simple-style or tell me, how to create unambiguous grammars in
define-cfg-style. Maybe I will provide a third macro to explicitly specify a complete cfg, so you can make sure it's unambiguous yourself (if anyone actually needs this).
- Christoph Finkensiep <email@example.com>
- MIT/X11, MIT, X11/MIT