Skip to content

Commit

Permalink
Cleanup docs/usage
Browse files Browse the repository at this point in the history
  • Loading branch information
knoebber committed Mar 17, 2024
1 parent f2d411c commit 40d7f1c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
36 changes: 31 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ Elixir nif binding for

## Installation

If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `ex_tree_sitter_highlight` to your list of dependencies in `mix.exs`:
Hex: https://hexdocs.pm/ex_tree_sitter_highlight/0.1.0

The package can be installed by adding `ex_tree_sitter_highlight` to your list of dependencies in `mix.exs`:

```elixir
def deps do
Expand All @@ -16,12 +17,37 @@ def deps do
end
```

## Examples
## Usage

**Supported languages:**

```
iex(1)> TreeSitterHighlight.get_supported_languages
[:c, :css, :elixir, :go, :haskell, :heex, :html, :javascript, :json, :rust]
```

**Render html:**
```
iex(1)> 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"}
```

```
**Get the default stylesheet:**
```
iex(3)> TreeSitterHighlight.get_default_css_content()
...output omitted...
```
## Example Output
This project's rust source code:
### This project's rust source code:
https://knoebber.github.io/ex_tree_sitter_highlight/example_output/ex_tree_sitter_highlight/rust.html
Comparison with [Elixir Makeup](https://github.com/elixir-makeup/makeup):
### Comparison with Elixir Makeup
https://knoebber.github.io/ex_tree_sitter_highlight/comparison.html
2 changes: 1 addition & 1 deletion lib/tree_sitter_highlight.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ defmodule TreeSitterHighlight do
See priv/default.css for an example of how to create your own stylesheet.
"""
def get_default_css_content() do
default_stylesheet() |> File.read()
default_stylesheet() |> File.read!()
end

@doc ~S"""
Expand Down
1 change: 0 additions & 1 deletion native/treesitterhighlight/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ static ELIXIR_CONFIG: Lazy<HighlightConfiguration> = Lazy::new(|| {
)
.unwrap();
c.configure(&HIGHLIGHT_NAMES);
println!("configured elixir");
c
});

Expand Down

0 comments on commit 40d7f1c

Please sign in to comment.