$currentListEntry = false;
$lastSection = null;
foreach ($lines as $line) {
    $line = trim($line, "\r");
    ++$lineNumber;
    if ($lineNumber == 1) {
        $newLines[] = array('type' => 'title', 'name' => $line);
        $newLines[] = '';
        continue;
    }
    if ($listCounter > 0) {
        if (isChangeEntry($line, $changeText)) {
            addListItem($listLines, $currentListEntry);
            $currentListEntry = $changeText;
        } else {
            if (isEmptyLine($line)) {
                addListItem($listLines, $currentListEntry);
                $currentListEntry = false;
                $listCounter = 0;
            } else {
                $currentListEntry .= ' ' . trim($line);
            }
        }
    } else {
        if (preg_match("/^(\\*?)(.+):/", $line, $matches)) {
            addListItem($listLines, $currentListEntry);
            $currentListEntry = false;
            createList($lastSection['items'], $listLines);
            $header = $matches[2];
            $headerLevel = 1;
            if (!$matches[1]) {
 ++$lineNumber;
 if ( $lineNumber == 1 )
 {
     $newLines[] = array( 'type' => 'title',
                          'name' => $line );
     $newLines[] = '';
     continue;
 }
 if ( $listCounter > 0 )
 {
     if ( isChangeEntry( $line, $changeText ) )
     {
         addListItem( $listLines, $currentListEntry );
         $currentListEntry = $changeText;
     }
     else if ( isEmptyLine( $line ) )
     {
         addListItem( $listLines, $currentListEntry );
         $currentListEntry = false;
         $listCounter = 0;
     }
     else
     {
         $currentListEntry .= ' ' . trim( $line );
     }
 }
 else if ( preg_match( "/^(\*?)(.+):/", $line, $matches ) )
 {
     addListItem( $listLines, $currentListEntry );
     $currentListEntry = false;
     createList( $lastSection['items'], $listLines );