rustled_syntect
An Elixir binding for syntect, a syntax highlighting library written in Rust.
Powered by Rustler.
Supports line by line streaming and outputs I/O lists for that awesome writev call!
Installation
Add rustled_syntect to your project’s dependencies in mix.exs:
def deps do
[
{:rustled_syntect, "~> 0.2.1"}
]
endAnd fetch your project’s dependencies:
$ mix deps.getUsage
iex> RustledSyntect.hilite_stream(["(0..69).each do |x|", " puts x", "end"], lang: "Ruby") |> Enum.into([]) |> IO.puts<span class="source ruby"><span class="punctuation definition group begin ruby">(</span><span class="constant numeric ruby">0</span><span class="keyword operator ruby">..</span><span class="constant numeric ruby">69</span><span class="punctuation definition group end ruby">)</span><span class="punctuation accessor ruby">.</span>each <span class="keyword control start-block ruby">do</span> <span class="meta block parameters ruby"><span class="punctuation definition parameters begin ruby">|</span></span><span class="meta block parameters ruby"><span class="variable parameter ruby">x</span><span class="meta block parameters ruby"><span class="punctuation definition parameters end ruby">|</span></span></span>
<span class="support function builtin ruby">puts</span> x
<span class="keyword control ruby">end</span></span>iex> RustledSyntect.supported_langs
[
%RustledSyntect.Syntax{
file_extensions: ["txt"],
first_line_match: nil,
name: "Plain Text"
},
%RustledSyntect.Syntax{
file_extensions: ["asa"],
first_line_match: nil,
name: "ASP"
},
%RustledSyntect.Syntax{
file_extensions: ["asp"],
first_line_match: nil,
name: "HTML (ASP)"
},
%RustledSyntect.Syntax{
file_extensions: ["as"],
first_line_match: nil,
name: "ActionScript"
},
%RustledSyntect.Syntax{
file_extensions: ["applescript", "script editor"],
first_line_match: "^#!.*(osascript)",
name: "AppleScript"
},
…
] License
Like Syntect itself, this binding is available under the MIT License.