chic

Package Version Hex Docs JavaScript-compatible

Type safe bindings for Shiki.

This is very early and experimental, expect breaking changes.

npm install shiki
gleam add chic@1
import chic
import gleam/io
import gleam/javascript/promise.{type Promise}

pub fn main() {
  use hl <- promise.await(
    chic.create_highlighter(["github-dark", "vitesse-dark"], [
      "javascript",
      "go",
      "gleam",
    ]),
  )

  let assert Ok(highlighter) = hl

  use html_js <- promise.await(chic.highlight(
    highlighter,
    "console.log('hello');",
    "javascript",
    "github-dark",
  ))

  case html_js {
    Ok(html) -> io.println(html)
    Error(e) -> {
      io.println(e)
    }
  }

  promise.resolve(Nil)
}

Further documentation can be found at https://hexdocs.pm/chic.

Development

gleam test  # Run the tests
Search Document