View Source TreeSitterHighlight (Elixir Tree Sitter Highlight v0.2.2)
Elixir binding for https://docs.rs/tree-sitter-highlight/latest/tree_sitter_highlight/
Summary
Functions
Returns CSS content with classes for highlighting and formatting html output. See priv/default.css for an example of how to create your own stylesheet. This stylesheet contains both a light and dark color scheme. To toggle the dark scheme set data-theme="dark" on the root <html> element.
Returns a language atom for the file, or nil if the language isn't supported.
Returns a list of supported language atoms.
Renders the given source code into html.
Writes a complete html document with highlighted code within. head_content should contain a stylesheet.
Functions
Returns CSS content with classes for highlighting and formatting html output. See priv/default.css for an example of how to create your own stylesheet. This stylesheet contains both a light and dark color scheme. To toggle the dark scheme set data-theme="dark" on the root <html> element.
Returns a language atom for the file, or nil if the language isn't supported.
Examples
iex> TreeSitterHighlight.get_language_from_filename("/path/file.ex")
:elixir
iex> TreeSitterHighlight.get_language_from_filename("/path/file.txt")
nil
Returns a list of supported language atoms.
Renders the given source code into html.
Examples
iex> TreeSitterHighlight.render_html("1", :elixir)
{:ok, "<pre class=\"code-block language-elixir\"><code>\n<div class=\"line-wrapper\"><span class=\"line-number\">1</span><span class=\"token number\">1</span>\n</div>\n</code></pre>\n"}
iex> TreeSitterHighlight.render_html("1", :txt)
{:error, :unsupported_language}
Writes a complete html document with highlighted code within. head_content should contain a stylesheet.
Example
iex> TreeSitterHighlight.write_highlighted_file(
...> "lib/tree_sitter_highlight.ex",
...> "example_output/ex_tree_sitter_highlight/tree_sitter_highlight.html",
...> "<style>#{TreeSitterHighlight.get_default_css_content()}</style>"
...> )
:ok