Add a spec to Parser.parse
This commit is contained in:
parent
2f21511749
commit
98d0555b17
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue