Packages

Content Management System for static sites, like Jekyll but with elixir/eex rather than liquid templates

Current section

Files

Jump to
dragon lib plugin markdown.ex
Raw

lib/plugin/markdown.ex

defmodule Dragon.Plugin.Markdown do
@moduledoc """
Dragon markdown plugin
"""
@behaviour Dragon.Plugin
@impl Dragon.Plugin
def run(_, _, path, _, content) do
case Path.extname(path) do
".md" ->
newname = Path.rootname(path) <> ".html"
case Earmark.as_html(content, escape: false) do
{:ok, content, _} -> {:ok, newname, content}
{:error, _ast, error} -> {:error, error}
end
_ ->
{:ok, path, content}
end
end
end