spruce/highlight

Syntax highlighting for source code using spruce styles.

Types

A resolved syntax language backed by a smalto grammar.

pub opaque type Language

A syntax highlighting theme for styled smalto token kinds.

pub opaque type Theme

Values

pub fn adaptive_theme() -> Theme

Build the default syntax highlighting theme with adaptive light/dark colors.

pub fn dark_theme() -> Theme

Build a syntax highlighting theme for dark terminal backgrounds.

pub fn highlight(
  sp: spruce.Spruce,
  code code: String,
  name name: String,
) -> String

Highlight code with the default adaptive theme, or return code unchanged for unknown languages.

pub fn highlight_named_with(
  sp: spruce.Spruce,
  code code: String,
  name name: String,
  theme theme: Theme,
) -> String

Highlight code with a string language name and explicit theme.

pub fn highlight_with(
  sp: spruce.Spruce,
  code: String,
  language: Language,
  theme: Theme,
) -> String

Highlight code with a resolved language and explicit theme.

pub fn language(name: String) -> Result(Language, Nil)

Resolve a language name or alias to a smalto-backed language.

pub fn light_theme() -> Theme

Build a syntax highlighting theme for light terminal backgrounds.

Search Document