function parse($text)
{
# standardize line breaks
$text = str_replace("\r\n", "\n", $text);
$text = str_replace("\r", "\n", $text);
# replace tabs with spaces
$text = str_replace("\t", ' ', $text);
# remove surrounding line breaks
$text = trim($text, "\n");
# split text into lines
$lines = explode("\n", $text);
# iterate through lines to identify blocks
$blocks = $this->findBlocks($lines);
# iterate through blocks to build markup
$markup = $this->compile($blocks);
# trim line breaks
$markup = trim($markup, "\n");
return $markup;
}