contour
Types
pub type Token {
Whitespace(String)
Keyword(String)
String(String)
Number(String)
Variant(String)
Function(String)
Module(String)
Operator(String)
Comment(String)
Other(String)
}
Constructors
-
Whitespace(String) -
Keyword(String) -
String(String) -
Number(String) -
Variant(String) -
Function(String) -
Module(String) -
Operator(String) -
Comment(String) -
Other(String)
Values
pub fn to_ansi(code: String) -> String
Highlight source code using ansi colours!
| Token | Colour |
|---|---|
| Keyword | Yellow |
| Module | Cyan |
| Variant | Cyan |
| Function | Blue |
| Operator | Magenta |
| Comment | Italic grey |
| String, Number | Green |
| Whitespace, other | No colour |
If you wish to use some other colours or other format entirely see
to_tokens.
pub fn to_html(code: String) -> String
Convert Gleam code into a HTML string! Each token is wrapped in a <span>
with a class indicating the type of token.
| Token | CSS class |
|---|---|
| Keyword | hl-keyword |
| Module | hl-module |
| Variant | hl-variant |
| Function | hl-function |
| Operator | hl-operator |
| Comment | hl-comment |
| Number | hl-number |
| String | hl-string |
| Whitespace, other |
Place the output within a <pre><code>...</code></pre> and add styling for
these CSS classes to get highlightin on your website. Here’s some CSS you
could use:
pre code .hl-comment { color: #d4d4d4; font-style: italic }
pre code .hl-function { color: #9ce7ff }
pre code .hl-keyword { color: #ffd596 }
pre code .hl-module { color: #ffddfa }
pre code .hl-number { color: #c8ffa7 }
pre code .hl-operator { color: #ffaff3 }
pre code .hl-string { color: #c8ffa7 }
pre code .hl-variant { color: #ffddfa }
If you wish to use some other format see to_tokens.