yogthos / markdown-clj

Markdown parser in Clojure
Eclipse Public License 1.0
540 stars 120 forks source link

Yaml front matter should handle empty lines and not require empty newline after delimiter #176

Closed Oddsor closed 2 years ago

Oddsor commented 2 years ago

Parsing markdown files with yaml front matter currently expects that the yaml data does not contain empty lines, and that an empty line exists after the ending dashes:

---
title: My Document
summary: A brief description of my document.
authors: 
  - Justin May
  - Spooky Mulder
  - End Line At End  
date: October 31, 2015
base_url: http://example.com
---

# The Document

However in most descriptions of yaml front matter I've seen you should also be able to include an arbitrary number of empty lines in the yaml definition as well as no empty line after the delimiter:

---
title: My Document
summary: A brief description of my document.
authors: 
  - Justin May
  - Spooky Mulder
  - End Line At End  
date: October 31, 2015
base_url: http://example.com

---
# The Document
Oddsor commented 2 years ago

In this proposed fix I've modified the yaml metadata test-file to include a few extra newlines: https://github.com/yogthos/markdown-clj/pull/177

The best way I could think of to get this done correctly (🤞 ) was to ensure that the parsers report how many lines they consume.

yogthos commented 2 years ago

Thanks, the fix looks good and I think we can close this one if everything looks ok on your end.

Oddsor commented 2 years ago

Brilliant, thanks! My yaml-mattered Markdown files now seem to parse better than before, the metadata often had lots of empty lines etc 😊

Happy holidays!