Markdown & YAML cheat sheet

Markdown

  • Paragraphs

    • Separate paragraphs with a blank line.

    • This is a paragraph of text.
      
      And another paragraph of text.
      
  • # — Headings

    • Start each heading with one or more hashes, followed by a space.

    • # Heading level 1
      ## Heading level 2
      ### Heading level 3
      
  • * — Italic

    • Wrap the words in single asterisks.

    • Some of *these* words *are* italic.
      
  • ** — Bold

    • Wrap the words in double asterisks.

    • **Some** of these **words** are bold.
      
  • - — Unordered list

    • Start each line with a dash and a space.

    • Indent before the dash for nested lists.

    • - List item 1
      - List item 2
        - Sub list item 1
      
  • 1. — Ordered list

    • Start each line with a number, period & space.

    • Indent before the number for nested lists.

    • 1. List item one
      2. List item two
        1. Sub list item one
      
  • []() — Link

    • [] — link text inside square brackets.

    • () — link URL inside round brackets.

    • [Dinosuars](https://en.wikipedia.org/wiki/Dinosaurs)
      
      The [New Horizons](http://pluto.jhuapl.edu/) space probe took photos of Pluto.
      
  • ![]() — Image

    • Start with an exclamation point.

    • [] — alt text inside square brackets.

    • () — image URL inside round brackets.

    • ![True colour composite of Pluto](true-colour-pluto.jpg)
      
  • --- — Horizontal rule

    • Three consecutive dashes on a single line.

    • ---
      
  • ` — Inline code

    • Surround code inside other text with single backticks.

    • The `<h1>` tag is the most important content on the page.
      
  • ``` — Code block

    • Start a line with three backticks to make a code block.

    • End the code block with three more backticks on their own line.

    • ```
      body {
        font-size: 100%;
      }
      ```
      
    • Optionally specify the code language after the opening backticks.

    • ```css
      body {
        font-size: 100%;
      }
      ```
      
  • - [ ] — Task list

    • Non standard. Start a list and used square brackets with a space to denote a task.

    • - [ ] Read sci-fi
      - [ ] Watch kaiju movie
      
    • Put an “x” between the square brackets to mark it as complete.

    • - [ ] Read sci-fi
      - [x] Watch kaiju movie
      

YAML

Always indent with two spaces.

  • term: value — Objects

    • Start with a term, no spaces, followed by a colon and a space.

    • name: "Tyrannosaurus"
      period: "Late Cretaceous"
      
    • Indent to create nested objects.

    • dimensions:
        width: "3 metres"
        height: "8 metres"
      
  • - value — Arrays

    • Start with a dash, and a space.

    • - "Other dinosaurs"
      - "Meat"
      
    • Arrays inside objects:

    • likes_to_eat:
        - "Other dinosaurs"
        - "Meat"
      
    • Objects inside arrays.

    • - name: "T. rex"
        period: "Late Cretaceous Period"
      
  • " — Escaping

    • Surround text with quotes (double or single) to escape text.

    • name_meaning: "tyrant & lizard"
      
    • In all the previous examples the quotes aren’t really necessary. But I find myself almost always adding them for clarity and to prevent myself from having to think about whether I need to escape the or not.

  • > — Folded text block

    • Start with a greater than, and indent the next lines.

    • The text will be collapsed into a single line when parsed.

    • desc: >
        Tyrannosaurus is a genus of coelurosaurian theropod dinosaur.
        The species Tyrannosaurus rex is one of the most well-represented of the large theropods.
      
  • | — Wrapped text block

    • Start with a vertical pipe, and indent the next lines.

    • The text will keep its multiple lines when parsed.

    • poem: |
        T. rex, T.rex
        How I love thee
      
  • --- — Front matter

    • YAML can be used at the top of Markdown documents to add more structured data.

    • Surround the YAML with two lines of consecutive dashes.

    • ---
      name: "Venus"
      discoverer: "Galileo Galilei"
      ---
      
      *Venus* is the second planet from the Sun, orbiting it every 224.7 Earth days.