A fast Djot parser and formatter for Elixir.
Djot parsing and transformations powered by the jotdown rust crate.
Simply call to_html
on a string that contains Djot data, and you'll get back a html fragment.
Djot.to_html("hello *world*!")
# => {:ok, "<p>hello <strong>world</strong>!</p>\n"}
If you want to write Djot contents inline in an Elixir program, you can use the provided sigil
import Djot.Sigil
~d"""
This is a Djot document. \
It will be compiled to HTML automatically, at compile time!
Here's some display math, thank you djot!
$$`
\frac{-b \pm \sqrt{b^2 - 4 a c}}{2 a}
`
"""
# => "<p>This is a Djot document. <br>\nIt will be compiled to HTML automatically, at compile time!</p>\n<p><span class=\"math display\">\\[\n\\frac{-b \\pm \\sqrt{b^2 - 4 a c}}{2 a}\n\\]</span></p>\n"
This can be useful when paired with tools such as the Tableau SSG
Add :djot
as a dependency:
def deps do
[
{:djot, "~> 0.1.0"}
]