Markdown metadata format

后端 未结 7 1251
独厮守ぢ
独厮守ぢ 2020-12-29 18:44

Is there a standard or convention for embedding metadata in a Markdown formatted post, such as the publication date or post author for conditional rendering by the renderer?

7条回答
  •  执笔经年
    2020-12-29 19:09

    This is not a standard way, but works with Markdown Extra.

    I wanted something that worked in the parser, but also didn't leave any clutter when I browse the files on Bitbucket where I store the files.

    So I use Abbreviations from the Markdown Extra syntax.

    *[blog-date]: 2018-04-27
    *[blog-tags]: foo,bar
    

    then I parse them with regexp:

     ^\*\[blog-date\]:\s*(.+)\s*$
    

    As long as I don't write the exact keywords in the text, they leave no trace. So use some prefix obscure enough to hide them.

提交回复
热议问题