-
Notifications
You must be signed in to change notification settings - Fork 7
Add a YAML FrontMatter metadata parser #57
base: master
Are you sure you want to change the base?
Add a YAML FrontMatter metadata parser #57
Conversation
@alfredbaudisch so far things are going well I am running into some problems I don't fully understand:
|
@rockchalkwushock nice, thanks for starting the pull request!
By the weekend I'll check it out. |
@alfredbaudisch I will play with it more tomorrow morning and see if I can get that figured out. I am close there is just something I am missing. |
@alfredbaudisch I am curious what you think about this idea, it would require some refactoring to the
- :binary.split(contents, ["\n---\n", "\r\n---\r\n"])
+ :binary.split(contents, ["<!-- -->"])
In making this change we side step the issue of the overlapping patterns with the ElixirMap and the YAML parser (or any future parser. From what I am seeing in the erlang docs for Elixir Map Format (default)%{
author: Turd Ferguson
date: 2021-11-20
title: That's a funny name
}
---
<!-- -->
Post content... YAML Format---
author: Turd Ferguson
date: 2021-11-20
title: That's a funny name
---
<!-- -->
Post content... Joplin Format
That's a funny name
<!-- -->
Post content...
Crude POC# base_parser.ex
# default metadata parser is ElixirMap
do_parse = fn split_contents ->
apply(parser, :parse, [path, split_contents, opts])
end
def parse(path, contents, opts) do
...
case :binary.split(contents, ["<!-- -->"]) do
[_] -> do_parse(contents)
[_, contents] -> do_parse(contents)
[attrs, contents] ->
# process `attrs` with corresponding parser
case do_parse(contents) do
{:ok, frontmatter, body} ->
{:ok, frontmatter, body}
other ->
other
end
end
end |
@rockchalkwushock I'm really bad with keeping track of my 10.000 personal projects. I'm very sorry for keeping you waiting on this one. I'll try to come back to it soon. |
@alfredbaudisch no worries I have been pretty busy as well. I will circle back this evening and give this another look. Perhaps I can get it over the hump. |
What does this PR do?
yaml.ex
for users to use as a metadata parser when they prefer to use YAML syntax for their front matter.Closes #41