notebook/IT/yaml.md
2021-04-20 21:01:21 +02:00

1.3 KiB

YAML

YAML (a recursive acronym for "YAML Ain't Markup Language") is a human-readable data-serialization language. It is commonly used for configuration files and in applications where data is being stored or transmitted. YAML targets many of the same communications applications as Extensible Markup Language (XML) but has a minimal syntax which intentionally differs from SGML. It uses both Python-style indentation to indicate nesting, and a more compact format that uses [...] for lists and {...} for maps making YAML 1.2 a superset of JSON.

Break long lines

  • Use > most of the time: interior line breaks are stripped out, although you get one at the end:

    key: >
      Your long
      string here.  
    
  • Use | if you want those line breaks to be preserved as \n (for instance, embedded markdown with paragraphs):

    key: |
      ### Heading
    
      * Bullet
      * Points  
    
  • Use >- or |- instead if you don't want a line break appended at the end.

  • Use "..." if you need to split lines in the middle of words or want to literally type line breaks as \n:

    key: "Antidisestab\
     lishmentarianism.\n\nGet on it."
    
  • YAML is crazy.