Pandoc::Metadata(3pm)
β¨ Pandoc::Metadata β¨
okay bestie, so this is the Pandoc::Metadata page from the User Contributed Perl Documentation β yep, perl, she's vintage but she SERVES π stay with me.
πΈ NAME πΈ
Pandoc::Metadata β pandoc document metadata. that's it, that's the name, short and iconic.
π¦ DESCRIPTION π¦
so like, document metadata?? author, title, date, all that?? it can be embedded in different document formats, which is lowkey kind of a lot when you think about it.
you can hand over your metadata in Pandoc markdown format using metadata blocks (http://pandoc.org/MANUAL.html#metadata-blocks) at the top of a markdown file β or in YAML format, like literally this:
---
title: a title
author:
- first author
- second author
published: true
...
and Pandoc supports document metadata built out of all of these:
- strings (
MetaString) - boolean values (
MetaBool) - lists (
MetaList) - key-value maps (
MetaMap) - lists of inline elements (
MetaInlines) - lists of block elements (
MetaBlocks)
simple strings and boolean values can also be specified straight through the pandoc command line option -M or --metadata, like:
pandoc -M key=string
pandoc -M key=false
pandoc -M key=true
pandoc -M key
and then the Perl module Pandoc::Elements exports functions to construct metadata elements in the internal document model β plus the general helper function metadata. π«Ά
π COMMON METHODS π
every single Metadata Element supports the common element methods β name, to_json, string, ... β and returns true for the method is_meta. no cap. β¨
π value( [ $key | $pointer ] [ %options ] ) π
call it with no argument and it hands you back an unblessed deep copy of the metadata element. cute, fresh, yours to keep. π
now, for peeking into subfields you've got options:
- plain keys at the root level β but ONLY if they don't start with
/ - JSON Pointer expressions (RFC 6901,
http://tools.ietf.org/html/rfc6901)
okay important: JSON Pointer escapes slash as~1and the character~as~0. and URI Fragment syntax is NOT supported. just so you know. π
look how pretty this is:
$doc->value; # full metadata
$doc->value(""); # full metadata, explicitly
$doc->value('/author'); # author field
$doc->value('author'); # author field, plain key
$doc->value('/author/name'); # name subfield of author field
$doc->value('/author/0'); # first author field
$doc->value('/author/0/name'); # name subfield of first author field
$doc->value('/~1~0'); # metadata field '/~'
$doc->value('/'); # field with empty string as key
returns undef if the selected field does not exist. rip. π
as a debugging aid you can set the option strict to a true value. in that case the method will croak if it runs into:
- an invalid pointer
- an invalid array index
- a non-existing key
- a non-existing array index
instances of MetaInlines and MetaBlocks get stringified β unless option element is set to keep.
and setting option boolean to JSON::PP will return JSON::PP:true or JSON::PP::false for MetaBool instances. star behavior honestly β
π METADATA ELEMENTS π
π MetaString π
a plain text string metadata value. simple. gorgeous. no notes.
MetaString $string
metadata "$string"
π MetaBool π
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()
π MetaList π
a list of other metadata elements. nesting rights!! πΈ
MetaList [ @values ]
metadata [ @values ]
π MetaMap π
a map of keys to other metadata elements. keys, meet values, values, meet keys π
MetaMap { %map }
metadata { %map }
π MetaInlines π
a container for a list of inlines in metadata.
MetaInlines [ @inlines ]
π MetaBlocks π
a container for a list of blocks in metadata.
MetaBlocks [ @blocks ]
and hiii, one more thing β the string method concatenates all stringified content blocks separated by empty lines. π§
and that's the whole page bestie, you ate it, you understood it, go forth and metadata responsibly π β¨
this was written by the π User Contributed Perl Documentation crew, running on perl v5.38.2, dated 2024-08-03 β mwah, bye π«Ά
π¦ where this page comes from
- debian trixie: libpandoc-elements-perl 0.38-7 Β· GPL-2.0-only
- ubuntu resolute: libpandoc-elements-perl 0.38-7 Β· GPL-2.0-only
- ubuntu stonking: libpandoc-elements-perl 0.38-7 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms