Refactor the zola regex out into a constant.
This commit is contained in:
parent
98d0555b17
commit
523b36d823
|
@ -1,5 +1,6 @@
|
|||
defmodule JOL.Blog.Parser do
|
||||
# Parses blog posts.
|
||||
@zola_post_regex ~r/\+\+\+\n(?<attrs>.*)\n\+\+\+\n\n(?<body>.*)/s
|
||||
|
||||
@doc """
|
||||
Psrses a Zola-style blogpost.
|
||||
"""
|
||||
|
@ -12,7 +13,7 @@ defmodule JOL.Blog.Parser do
|
|||
}, String.t()}
|
||||
def parse(_path, content) do
|
||||
%{"attrs" => attrs, "body" => body} =
|
||||
Regex.named_captures(~r/\+\+\+\n(?<attrs>.*)\n\+\+\+\n\n(?<body>.*)/s, content)
|
||||
Regex.named_captures(@zola_post_regex, content)
|
||||
|
||||
{:ok, toml_attrs} = Toml.decode(attrs)
|
||||
|
||||
|
|
Loading…
Reference in a new issue