defmodule Mf2WasmEditor do @moduledoc """ Browser-side MF2 syntax highlighter for Phoenix LiveView apps. Ships three things: * The web-tree-sitter runtime (`web-tree-sitter.js` + `.wasm`). * The compiled `tree-sitter-mf2` grammar (`tree-sitter-mf2.wasm`). * A Phoenix LiveView hook (`mf2_editor.js`) that wires a transparent textarea + highlighted `
` into the grammar,
highlighting and surfacing diagnostics on every keystroke —
with no server round trip.
The hook is an ES module that imports web-tree-sitter directly.
One `)
iex> Mf2WasmEditor.script_tags(base_url: "/assets/mf2")
~s()
"""
@spec script_tags(keyword()) :: binary()
def script_tags(options \\ []) do
base_url = Keyword.get(options, :base_url, "/mf2_editor")
~s()
end
@doc """
File names served from `priv/static/`. Pass to
`Plug.Static`'s `:only` option so nothing else in the package is
exposed.
### Examples
iex> Mf2WasmEditor.static_paths()
["highlights.scm", "mf2_editor.js", "tree-sitter-mf2.wasm",
"web-tree-sitter.js", "web-tree-sitter.wasm"]
"""
@spec static_paths() :: [String.t()]
def static_paths do
~w(highlights.scm mf2_editor.js tree-sitter-mf2.wasm
web-tree-sitter.js web-tree-sitter.wasm)
end
end