Skip to content

๐Ÿ“‹ YAML

YAML Ain't Markup Language

Front Matter

Front matter is metadata written in YAML, located at the top of a file and wrapped between ---.

---
title: ๐Ÿ’Ž Miscellaneous
author: Simon Marquis
lang: en
keywords:
  - Miscellaneous
  - Random
---

Types

!!null

Devoid of value.

regexp

~ # (canonical)
|null|Null|NULL # (English)
| # (Empty)
# A document may be null.
---
empty:
canonical: ~
english: null
english2: Null
english3: NULL
~: null key

!!bool

Mathematical Booleans.

regexp

y|Y|yes|Yes|YES|n|N|no|No|NO
|true|True|TRUE|false|False|FALSE
|on|On|ON|off|Off|OFF
canonical: y
answer: NO
logical: True
option: on

!!int

Mathematical integers.

regexp

[-+]?0b[0-1_]+ # (base 2)
|[-+]?0[0-7_]+ # (base 8)
|[-+]?(0|[1-9][0-9_]*) # (base 10)
|[-+]?0x[0-9a-fA-F_]+ # (base 16)
|[-+]?[1-9][0-9_]*(:[0-5]?[0-9])+ # (base 60)
canonical: 685230
decimal: +685_230
octal: 02472256
hexadecimal: 0x_0A_74_AE
binary: 0b1010_0111_0100_1010_1110
sexagesimal: 190:20:30

!!float

Floating-point approximation to real numbers.

regexp

[-+]?([0-9][0-9_]*)?\.[0-9.]*([eE][-+][0-9]+)? (base 10)
|[-+]?[0-9][0-9_]*(:[0-5]?[0-9])+\.[0-9_]* (base 60)
|[-+]?\.(inf|Inf|INF) # (infinity)
|\.(nan|NaN|NAN) # (not a number)
canonical: 6.8523015e+5
exponentioal: 685.230_15e+03
fixed: 685_230.15
sexagesimal: 190:20:30.15
negative infinity: -.inf
not a number: .NaN

!!str

Unicode strings, a sequence of zero or more Unicode characters.

canonical: Hello, World!
single quotes: 'Hello, World!'
double quotes: "Hello, World!"
folded: >
  Hello,
  World!
literal: |
  Hello,
  World!
  • Block Scalar Style ๐Ÿ”—

    • folded (>): converts new lines into spaces
    • literal (|): preserves new lines and trailing spaces
  • Block Chomping ๐Ÿ”—

    • clip: single newline at end
    • strip (-): no newline at end
    • keep (+): all newlines from end

๐Ÿ”—

!!timestamp

A point in time.

regexp

[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] # (ymd)
|[0-9][0-9][0-9][0-9] # (year)
 -[0-9][0-9]? # (month)
 -[0-9][0-9]? # (day)
 ([Tt]|[ \t]+)[0-9][0-9]? # (hour)
 :[0-9][0-9] # (minute)
 :[0-9][0-9] # (second)
 (\.[0-9]*)? # (fraction)
 (([ \t]*)Z|[-+][0-9][0-9]?(:[0-9][0-9])?)? # (time zone)
canonical:        2001-12-15T02:59:43.1Z
valid iso8601:    2001-12-14t21:59:43.10-05:00
space separated:  2001-12-14 21:59:43.10 -5
no time zone (Z): 2001-12-15 2:59:43.10
date (00:00:00Z): 2002-12-14

!!binary

A sequence of zero or more octets (8 bit values).

canonical: !!binary "\
 R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
generic: !binary |
 R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==

!!seq

Collections indexed by sequential integers starting with zero.

Block style: !!seq
- A
- B
- C
Flow style: !!seq [ A, B, C ]

!!set

Unordered set of non-equal values.

Block style: !!set
  ? A
  ? B
  ? C
Flow style: !!set { A, B, C }

!!pairs

Ordered sequence of key:value pairs allowing duplicates.

Block style: !!pairs
  - A: a
  - B: b
  - C: c
Flow style: !!pairs [ A: a, B: b, C: c ]

!!map

Associative container, where each key is unique in the association and mapped to exactly one value.

Block style: !!map
  A: a
  B: b
  C: c
Flow style: !!map { A: a, B: b, C: c }

!!omap

Ordered sequence of key:value pairs without duplicates.

Block style: !!omap
  A: a
  B: b
  C: c
Flow style: !!omap { A: a, B: b, C: c }