yogthos/markdown-clj

Add support for YAML metadata

metasoarous opened this issue · 3 comments

As pointed out in this nice Stack Overflow answer, YAML section markers are another nice way of specifying metadata. For instance, this is how Jekyll does its metadata specifications. And as pointed out in the SO post, this syntax is also supported by pandoc, a popular Linux markdown processing utility.

Here's a small sample:

---
title: Introduction
author: "Bob Jones"
---

# Hello

I see from #46 that MultiMarkdown notation is supported as follows:

(markdown.core/md-to-html-string* "Title: title\nAuthor: brunokim\n\nFirst paragraph." [:parse-meta? true])
=> {:metadata {:title ["title"], :author ["brunokim"]}, :html "<p>First paragraph.</p>"}

Support for processing YAML metadata could either be added directly to the :parse-meta? true option, or to a separate :parse-yaml-meta? true option. Or both, for the matter. I'd also support adding an option for processing EDN, as suggested in #46.

Would you consider a PR with this functionality? If so, what shape do you think it should take?

Thanks!

This sounds like a reasonable addition to me. I think that using :parse-meta? directly would be the most ergonomic approach as long as the format can be inferred deterministically. And agree regarding supporting EDN as well.

Wonderful! Thank you @yogthos!

No problem, and thanks for the PR.