Current section

Files

Jump to
contour README.md
Raw

README.md

# Contour đŸ’…
A Gleam syntax highlighter in Gleam
[![Package Version](https://img.shields.io/hexpm/v/contour)](https://hex.pm/packages/contour)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/contour/)
```sh
gleam add contour@1
```
```gleam
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_html(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>.