lightning-rs icon indicating copy to clipboard operation
lightning-rs copied to clipboard

Parse post YAML metadata

Open chriskrycho opened this issue 8 years ago • 0 comments

Posts begin with blocks of YAML metadata, delimited by --- (initial, on the first line) and --- or ... (terminal):

---
Title: foo
Date: now
...

or

---
Title: bar
Date: then
---

(I want to support both because the ...-delimited version is supported by Pandoc.)

A few caveats:

  • There needs to be a configurable option whether to treat comma-separated values as distinct in taxonomies which support multiple values, e.g. should Tags: foo, bar, quux, baz be parsed as a Tags key with a single String property of "foo, bar, quux, baz", or as a Vec<String> of ["foo", "bar", "quux", "baz"]? The former is not standard YAML, but is necessary for supporting imports from Pelican. (Alternative: provide a rewriter? It would have to be very well tested.)

  • The behavior for passing through to Pandoc is potentially different from that needed for e.g. pulldown-cmark. Pandoc will extract e.g. bibliographical info from YAML blocks, and render it into the page. pulldown-cmark definitely won't do that (and neither will hoedown or anything else). So either:

    • that information needs to be extracted and then passed to pandoc, or
    • that information needs to be left attached for the string passed to pandoc but not for any other Markdown processor.

    In general, I think my preference would be to just extract all the information and hand it to a function which wraps calling the Markdown processor, and then that function can hand it off to the Markdown processor as appropriate. E.g. in Pandoc's case, calling it with the appropriate arguments derived from the YAML metadata, rather than including the metadata in the text.

chriskrycho avatar Dec 24 '16 16:12 chriskrycho