See the docs on writing code in markdown.

Trust the geeks, they’ve got this sorted. Here’s a code block from xkcd.

int random()
     return 5; // Chosen by dice roll, guaranteed to be random

What about two consecutive clode blocks? Here’s some YAML book metadata from this project, followed by some funny code from StackOverflow.

  # The name of the organisation or entity that owns this project
  organisation: "Electric Book Works"
  # A live web address for the organisation
  url: ""
  # The name of the project of books in this folder.
  name: "The Electric Book workflow"
// Replaces with spaces the braces in cases where braces in places cause stasis 
   $str = str_replace(array("\{","\}")," ",$str);