From 523b36d8234e5d235b5eec9da1e4464740a16ad3 Mon Sep 17 00:00:00 2001 From: Jessica Phoenix Canady Date: Thu, 23 May 2024 16:47:48 -0400 Subject: [PATCH] Refactor the zola regex out into a constant. --- lib/jol/blog/parser.ex | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/jol/blog/parser.ex b/lib/jol/blog/parser.ex index 4a72c51..f303adf 100644 --- a/lib/jol/blog/parser.ex +++ b/lib/jol/blog/parser.ex @@ -1,5 +1,6 @@ defmodule JOL.Blog.Parser do - # Parses blog posts. + @zola_post_regex ~r/\+\+\+\n(?.*)\n\+\+\+\n\n(?.*)/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(?.*)\n\+\+\+\n\n(?.*)/s, content) + Regex.named_captures(@zola_post_regex, content) {:ok, toml_attrs} = Toml.decode(attrs)