Pearly v0.1.1 Pearly View Source
Pearly Soames wanted gold and silver, but not, in the way of common thieves, for wealth. He wanted them because they shone and were pure. Strange, afflicted, and deformed, he sought a cure in the abstract relation of colors. -- Mark Helprin, Winter's Tale
Pearly is an Elixir library for syntax highlighting using Sublime Text syntax definitions.
Pearly.highlight("html", "<h1>Hello, World!</h1>",
format: :html,
theme: "Solarized (dark)")
#=> {:ok, "<pre style="background-color:#002b36;">\n<span style=..."}
Pearly currently supports formatting output for either HTML pages or the terminal.
Dependencies
Pearly depends on the Rust library Syntect, and you will need to have the Rust compiler installed.
Additionally, one of Syntect's dependencies (Onig) requires cmake to be installed.
Link to this section Summary
Functions
Returns a string of source
highlighted according to lang
, where lang
may be a language extension or name. The :format
and :theme
of the
output may optionally be provided, defaulting to :html
and
"Solarized (dark)"
respectively
Link to this section Types
Link to this section Functions
Returns a string of source
highlighted according to lang
, where lang
may be a language extension or name. The :format
and :theme
of the
output may optionally be provided, defaulting to :html
and
"Solarized (dark)"
respectively.
If lang
is unknown, returns source
unmodified.
Options
:format
- Specifies the format of output. Currently supports either:html
or:terminal
. Defaults to:html
.:theme
- Specifies which them is used when highlighting. Defaults to"Solarized (dark)"
and currently supports:"Solarized (light)"
"Solarized (dark)"
"base16-ocean.light"
"base16-ocean.dark"
"base16-mocha.dark"
"base16-eighties.dark"
"InspiredGitHub"
Examples
iex> Pearly.highlight("html", "<br>", format: :terminal)
{:ok, "\e[48;2;0;43;54m\e[38;2;88;110;117m<\e[48;2;0;43;54m\e[38;2;38;139;210mbr\e[48;2;0;43;54m\e[38;2;88;110;117m>"}