Contour 💅
A Gleam syntax highlighter in Gleam
gleam add contour@1
import contour
pub fn main() {
let source =
"import gleam/io
pub fn main() {
io.println(\"hello, friend!\")
}"
// Highlight using ansi codes, suitable for showing in the terminal
contour.to_ansi(source)
|> io.println
// Convert to HTML with CSS classes for colours
let html = contour.to_ansi(source)
io.println("<pre><code>" <> html <> "</code></pre>")
// Or convert to tokens and the highlight in any way you desire
contour.to_tokens(source)
|> do_something_with_tokens
}
Further documentation can be found at https://hexdocs.pm/contour.