Add a spec to Parser.parse

This commit is contained in:
Jessica Canady 2024-05-23 16:46:43 -04:00
parent 2f21511749
commit 98d0555b17
Signed by: phoenix
SSH key fingerprint: SHA256:aaLOzOrLi+0n4eDZNQKH97PehwRt6KSE5fYJc+ZRKCQ

View file

@ -1,5 +1,15 @@
defmodule JOL.Blog.Parser do defmodule JOL.Blog.Parser do
# Parses blog posts. # Parses blog posts.
@doc """
Psrses a Zola-style blogpost.
"""
@spec parse(String.t(), String.t()) ::
{%{
date: DateTime.t(),
draft: boolean(),
tags: [String.t()],
title: String.t()
}, String.t()}
def parse(_path, content) do def parse(_path, content) do
%{"attrs" => attrs, "body" => body} = %{"attrs" => attrs, "body" => body} =
Regex.named_captures(~r/\+\+\+\n(?<attrs>.*)\n\+\+\+\n\n(?<body>.*)/s, content) Regex.named_captures(~r/\+\+\+\n(?<attrs>.*)\n\+\+\+\n\n(?<body>.*)/s, content)