Text::FrontMatter::YAML - read the "YAML front matter" format

DESCRIPTION

Text::FrontMatter::YAML opens files with so-called "YAML front matter",
such as are found on GitHub (and used in Jekyll, and various other
programs). It's a way of associating metadata with a file by marking off
the metadata into a YAML section at the top of the file.

You can create an object from a string containing a full document (say,
the contents of a file), or from a hashref (to turn into the YAML front
matter) and a string (for the rest of the file data). The object can't be
altered once it's created.


SYNOPSIS

    use File::Slurp;
    use Text::FrontMatter::YAML;

    # READING
    my $text_with_frontmatter = read_file("filename.md");
    my $tfm = Text::FrontMatter::YAML->new(
        document_string => $text_with_frontmatter
    );

    my $hashref  = $tfm->frontmatter_hashref;
    my $mumble   = $hashref->{'mumble'};
    my $data     = $tfm->data_text;

    # or also

    my $fh = $tfm->data_fh();
    while (defined(my $line = <$fh>)) {
        # do something with the file data
    }

    # WRITING
    my $tfm = Text::FrontMatter::YAML->new(
        frontmatter_hashref => {
            title => 'The first sentence of the "Gettysburg Address"',
            author => 'Abraham Lincoln',
            date => 18631119
        },
        data_text => "Four score and seven years ago...",
    );

    write_file("gettysburg.md", $tfm->document_string);


INSTALLATION

To install this module, run the following commands:

    perl Makefile.PL
    make
    make test
    make install


FUTURE DIRECTIONS

Text::FrontMatter::YAML uses YAML::Tiny. Perhaps it would be useful to
support more than one YAML module. Perhaps that would be more trouble
that it's worth. Thoughts?


SUPPORT AND DOCUMENTATION

After installing, you can find documentation for this module with the
perldoc command.

    perldoc Text::FrontMatter::YAML

Send questions, feature requests, and bug reports to me at
C<ahall@vitaphone.net>. Please include C<Text::FrontMatter::YAML> in the
subject line of the e-mail. Thanks!


LICENSE AND COPYRIGHT

Copyright 2013-2022 Aaron Hall.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl 5.10.1.

See http://dev.perl.org/licenses/ for more information.