waiting-for-dev / front_matter_parser

Ruby library to parse files or strings with a front matter. It has automatic syntax detection.
MIT License
105 stars 12 forks source link

Front matter data in documents without content parsed as content #13

Open ralfebert opened 3 years ago

ralfebert commented 3 years ago

For a document that contains only a front matter block but no content, FrontMatterParser returns the front matter data as content:

FrontMatterParser::Parser.new(:md).call("---\ntest: 1\n---")
 => #<FrontMatterParser::Parsed:0x0000000128c1d008 @front_matter={}, @content="---\ntest: 1\n---">

(Adding just a single newline after the block makes it parse correctly)

waiting-for-dev commented 3 years ago

Thanks for reporting, @ralfebert. Does it happen with any syntax?

I won't be able to look into it for a month at least, so feel free to submit a PR if it's something urgent for you. Otherwise, I'll happily look into it once I'm back.