Scroll to navigation

Pandoc::Metadata(3pm) User Contributed Perl Documentation Pandoc::Metadata(3pm)


Pandoc::Metadata - pandoc document metadata


Document metadata such as author, title, and date can be embedded in different documents formats. Metadata can be provided in Pandoc markdown format with metadata blocks <> at the top of a markdown file or in YAML format like this:

  title: a title
    - first author
    - second author
  published: true

Pandoc supports document metadata build of strings ("MetaString"), boolean values ("MetaBool"), lists ("MetaList"), key-value maps ("MetaMap"), lists of inline elements ("MetaInlines") and lists of block elements ("MetaBlocks"). Simple strings and boolean values can also be specified via pandoc command line option "-M" or "--metadata":

  pandoc -M key=string
  pandoc -M key=false
  pandoc -M key=true
  pandoc -M key

Perl module Pandoc::Elements exports functions to construct metadata elements in the internal document model and the general helper function "metadata".


All "Meta..." elements support common element methods ("to_json", "name", ...) and return true for method "is_meta". Method "content" returns the blessed data structure and "value" returns an unblessed copy:

  $doc->meta->{author}->content->[0];   # MetaInlines
  $doc->meta->value('author')->[0];     # plain string

value( [ $field ] )

Called without an argument this method returns an unblessed deep copy of the metadata elements or "undef" if the given (sub)field does not exist.

Can also be called with the alias "metavalue".


A plain text string metadata value.

    MetaString $string
    metadata "$string"


A Boolean metadata value. The special values "false" and "FALSE" are recognized as false in addition to normal false values (0, "undef", "", ...).

    MetaBool $value
    metadata JSON::true()
    metadata JSON::false()


A list of other metadata elements.

    MetaList [ @values ]
    metadata [ @values ]


A map of keys to other metadata elements.

    MetaMap { %map }
    metadata { %map }


Container for a list of inlines in metadata.

    MetaInlines [ @inlines ]


Container for a list of blocks in metadata.

    MetaBlocks [ @blocks ]
2017-03-31 perl v5.24.1