sloane.sh/lib/sloane_sh/front_matter.ex

18 lines
361 B
Elixir
Raw Normal View History

2024-02-24 08:03:18 -05:00
defmodule SloaneSH.FrontMatter do
@moduledoc """
Parses TOML front matter out put files
"""
2024-02-24 13:16:56 -05:00
def parse("+++" <> rest) do
2024-03-09 09:38:18 -05:00
[toml, body] = String.split(rest, ["+++\n", "+++\r\n"], parts: 2) |> dbg()
2024-02-24 08:03:18 -05:00
with {:ok, attrs} <- Toml.decode(toml, keys: :atoms) do
{:ok, attrs, body}
end
end
2024-02-24 13:16:56 -05:00
def parse(body) do
2024-02-24 08:03:18 -05:00
{:ok, %{}, body}
end
end