View Source Autumn (Autumn v0.1.4)
Syntax highlighter for source code parsed with Tree-Sitter and styled with Helix Editor themes.
Features
- Support multiple languages and 100+ themes. Check out some samples at https://autumn-30n.pages.dev
- Used by MDEx - a fast 100% CommonMark-compatible GitHub Flavored Markdown parser and formatter for Elixir
- Use Rust's inkjet crate under the hood
Installation
Add :autumn
dependency:
def deps do
[
{:autumn, "~> 0.1"}
]
end
Usage
Autumn.highlight!("elixir", "Atom.to_string(:elixir)") |> IO.puts()
#=> <pre class="autumn highlight" style="background-color: #282C34; color: #ABB2BF;">
#=> <code class="language-elixir" translate="no">
#=> <span class="namespace" style="color: #61AFEF;">Atom</span><span class="operator" style="color: #C678DD;">.</span><span class="function" style="color: #61AFEF;">to_string</span><span class="" style="color: #ABB2BF;">(</span><span class="string" style="color: #98C379;">:elixir</span><span class="" style="color: #ABB2BF;">)</span>
#=> </code></pre>
Autumn.highlight!("rb", "Math.sqrt(9)", theme: "dracula") |> IO.puts()
#=> <pre class="autumn highlight" style="background-color: #282A36; color: #f8f8f2;">
#=> <code class="language-ruby" translate="no">
#=> <span class="constructor" style="color: #BD93F9;">Math</span><span class="punctuation delimiter" style="color: #f8f8f2;">.</span><span class="function method" style="color: #50fa7b;">sqrt</span><span class="punctuation bracket" style="color: #f8f8f2;">(</span><span class="constant numeric" style="color: #BD93F9;">9</span><span class="punctuation bracket" style="color: #f8f8f2;">)</span>
#=> </code></pre>
Samples
Visit https://autumn-30n.pages.dev to see all available samples like the ones below:


Looking for help with your Elixir project?

At DockYard we are ready to help you build your next Elixir project. We have a unique expertise in Elixir and Phoenix development that is unmatched and we love to write about Elixir.
Have a project in mind? Get in touch!
Acknowledgements
- Logo created by by pongsakornRed - Flaticon
- Logo font designed by Astigmatic
Summary
Types
A language name, filename, or extesion.
Functions
Highlights the source_code
using the tree-sitter grammar for lang_filename_ext
.
Same as highlight/3
but raises in case of failure.
Types
Functions
@spec highlight(lang_filename_ext(), String.t(), keyword()) :: {:ok, String.t()} | {:error, term()}
Highlights the source_code
using the tree-sitter grammar for lang_filename_ext
.
Options
:theme
(default"onedark"
) - accepts any theme listed here, you should pass the filename without special chars and without extension. For example you should passtheme: "adwaita_dark"
to use the Adwaita Dark theme or passtheme: "penumbra"
to use the Penumbra+ theme, and so on.:pre_class
(default:"autumn highlight"
) - the CSS class to inject into the<pre>
tag.:code_class
(deafult:nil
) - the CSS class to inject into the<code>
tag, it's dynamically generated as"language-{name}
when the value isnil
.
@spec highlight!(lang_filename_ext(), String.t(), keyword()) :: String.t()
Same as highlight/3
but raises in case of failure.