memo

Yaml frontmatter

1

title: dummy
date: 2015-00-00 00:00

2

layout: post
title: "今日の日記"
date: 2015-05-02 23:45
categories: [diary]

3

layout: default.hbs
title: Early humans discovered...
description: Lots of things, because they were early humans.
date: 2013-07-04
categories:
- anthropology
- unibrows
- various wooly animals
tags:
- rocks
- wheel
- 30 inch wooden rims
published: false

4

layout: post
title: Using Variables in YAML Front Matter
date: 2014-05-30 09:08
tags: yaml, middleman

正規表現

Perl

#!/usr/bin/perl

use Text::FrontMatter::YAML;

my $tfm = Text::FrontMatter::YAML->new( fh => main::DATA );
my $metadata = $tfm->get_frontmatter_hashref;

print qq(This is $metadata->{artist} with "$metadata->{title}":\n\n);
print $tfm->get_data_text;

PHP

<?php
$yaml = yaml_parse($metadata);
$yaml_copy = [];
foreach ($yaml as $k => $v) {
    // copy the data you wish to preserve to $yaml_copy
    if (...) {
        $yaml_copy[$k] = $yaml[$k];
    }
}

2015-05-04 00:06 tags:MarkdownYAML frontmatter