picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.81k stars 616 forks source link

Concerns about YAML header #614

Closed chrisaga closed 2 years ago

chrisaga commented 2 years ago

Context : I try to make markdown pages an post them on the web via picocms and make a pdf and or epub document via pandoc. The idea of having an unique set of markdown files to do both seems very smart to me.

YAML concern 1: picocms' documentation and example uses YAML variables starting with a capital letter (e.g. Title:) which becomes lower case in the twig template (e.g. meta.tile). I don't know if there is a YAML norm for that, but pandoc doesn't recognize variables starting with caps. I tried using only lower case variables in my files and picocms doesn't seem to bother. I am safe with that ?

YAML concern 2: the syntax image: %assets_url%/image.jpg seems to be wrong in YAML. picoms encourages it and plain pandoc seems to allow it. On the contrary, pandoc's Lua filters (I need them) and ghostwriter (markdown editor) complains :

using token: found character that cannot start any token

Starting a YAML value with % is apparently illegal. I tried to escape it with a \% but there is no escaping here and the resulting url start with \https://…

Could we consider it as a (minor) bug in picocms ? What the workaround could be ?

PhrozenByte commented 2 years ago

picocms' documentation and example uses YAML variables starting with a capital letter (e.g. Title:) which becomes lower case in the twig template (e.g. meta.tile).

The YAML standard defines keys to be case sensitive. However, Pico will lowercase known headers like the mentioned Title by default (there's an ongoing discussion about whether this is a good idea and what Pico should do instead). To be safe you can choose to always use lowercase headers. Make sure that your theme also uses lowercase keys then.

the syntax image: %assets_url%/image.jpg seems to be wrong in YAML.

An unquoted % as first character is indeed illegal in newer versions of the standard. The docs need updating here (@mayamcdougall). However, % still is totally fine in general, it just needs quoting if it's used as first character. Use image: "%assets_url%/image.jpg" instead.

chrisaga commented 2 years ago

Great ! Thanks so much for the quick answer @PhrozenByte. I am new to Pico and I already love it very much. You solved the two little issues which prevented me to be totally happy with it (for now ;-) )