This project is read-only.

Minute Four: A Lot More Words

You receive a message back from the post office with some comments.

---
Concerning Car Washes: >

  We are sorry to have misplaced this letter.
  We were told by a reliable source that you
  were the owner of "Hank Bros.: the Car Wash!".

  Sorry.

The post office has screwed up, but they've also taught us about a very cool feature in YAML. They've used a block in their message.

In YAML, a block is a block of text. The block is indented one space or more.

Notice the little angle bracket: >. This indicates the beginning of a folded block. The folded block means that sentences which are right next to each other flow together as a paragraph. The block is read as a human would read it.

A YAML reader sees the above block as two lines, separated by a single carriage return.

Controlling Words

Their message continues.

Concerning "Jim O'Connor": |

  You are receiving Jim O'Connor's mail for several reasons:
  - The nameplate on your mailbox still says his name.
  - He has told our postman that you screen his mail.
  - He is living in your ceiling.
  - He held a raygun to the postman's head.

Hmm. This guy sounds totally eccentric. But notice that instead of an angle bracket, the post office has placed a straight line before the block. What could this mean?

A straight line (or pipe) character indicates the beginning of a literal block. The literal block means that every sentence is each separate in its own paragraph. The block is treated literally as a computer would read it.

A YAML reader sees the above block as five (six? –MQR) lines (the first line is blank).

Let's wrap this up: MinuteFive

Last edited Dec 21, 2009 at 9:10 PM by BurtHarris, version 2

Comments

havenskys Feb 12, 2009 at 9:43 PM 
Is the first line containing only a carriage return ommited?
Is it reasonable to use a regular expression search and replace to clear all forms of preceeding white space s/^\s+//s from blocks?