zine icon indicating copy to clipboard operation
zine copied to clipboard

Alternative frontmatter end / body start indicator

Open AvdN opened this issue 6 months ago • 2 comments

I propose to change the end frontmatter end indictor from --- to --- |, or at least allow the presence of the |. This proposal does not affect the initial --- in the .md files.

The rationale for this is that this little change makes the combination of the frontmatter and the markdown body into a valid multi-document YAML file that can be processed, and generated using any, standards conforming, YAML parser, without the need to explicitly split the header from body. The only restriction for this to work for most standard conforming parsers is that the body (i.e. the markdown) should not contain lines starting with ... or --- followed by whitespace, but even this is not a requirement for all parsers (assuming you tell them up front how many documents are in the stream).

For those not familiar with the YAML specification:

  • the --- at the beginning of a line, followed by whitespace, is the end-of-directives marker in YAML. In the absence of directives ( %YAML, %TAG) there is no need for a preceding document in a YAML document stream to be ended with an end-of-document directive (...), and documents can just be seperated by the end-of-directives marker.
  • YAML documents starting with --- | consist of a single literal scalar. Such a "root-level" scalar, does not have to be indented and should be loaded keeping the linebreaks intact.
  • YAML is a superset of JSON since the 1.2 specification (from 2009), so that existing standards conforming utilities/parsers can be used to easily update the header information.

If acceptable I can write a PR for this change.

AvdN avatar Feb 11 '24 09:02 AvdN