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)

Functions

pub fn to_ansi(code: String) -> String

Highlight source code using ansi colours!

TokenColour
KeywordYellow
ModuleCyan
VariantGreen
FunctionBlue
OperatorMagenta
CommentItalic grey
String, NumberGreen
Whitespace, otherNo colour

If you wish to use some other colours or other format entirely see to_tokens.

pub fn to_tokens(code: String) -> List(Token)

Convert Gleam source code to a list of tokens, which you can then convert into whatever format you want.

If you wish to print to the terminal using ansi colours see to_ansi.

Search Document