/**
  * @param string                  $col col content
  * @param \ViKon\Parser\TokenList $tokenList
  */
 private function parseCol($col, TokenList $tokenList)
 {
     $startRule = $this->set->getStartRule();
     $colTokenList = $this->parseContent($col);
     for ($i = 0; $i < count($colTokenList); $i++) {
         if ($colTokenList->getTokenAt($i)->getName() === $this->name) {
             $token = $colTokenList->getTokenAt($i);
             $colTokenList->removeTokenAt($i);
             $colTokenList->insertTokenAt($startRule->getName(), $token->getPosition(), $i)->set('content', $token->get('content', ''));
         }
     }
     $tokenList->merge($colTokenList);
 }
 /**
  * Parse list content and
  *
  * @param \ViKon\Parser\TokenList $tokenList
  */
 protected function parseListContent(TokenList $tokenList)
 {
     $lastToken = $tokenList->last();
     if ($lastToken->getName() === $this->name) {
         $tokenList->removeTokenAt(-1);
         // Remove last LIST_BLOCK (content)
         $content = $lastToken->get('content', '');
         $containsParagraphs = $tokenList->last()->get('forceParagraph', false);
         if (preg_match('/(?:\\n(?:[ \\t]*(?=\\n))?){2,}/i', $content) === 1) {
             $containsParagraphs = true;
             // Remove starting spaces or tab
             $content = explode("\n", $content);
             $pad = null;
             foreach ($content as $index => &$item) {
                 // Find out lin starting space length up to 4 characters
                 if ($pad === null && $index > 0 && preg_match('/^[ \\t]*$/i', $item) !== 1) {
                     if (preg_match('/^[ ]{0,4}/', $item, $matches) === 1) {
                         $pad = strlen($matches[0]);
                     } else {
                         $pad = 4;
                     }
                 }
                 // Remove line starting space or tab characters
                 if ($pad !== null) {
                     $item = preg_replace('/^(?: {' . $pad . '}|\\t)/', '', $item);
                 }
             }
             $content = implode("\n", $content);
         }
         $content = "\n" . $content . "\n";
         $contentTokenList = $this->parseContent($content, null, true);
         // Remove beginning and ending new line feed
         if ($contentTokenList->first()->getName() === EolRule::NAME && $contentTokenList->last()->getName() === EolRule::NAME) {
             $contentTokenList->removeTokenAt(0);
             // Remove first EOL
             $contentTokenList->removeTokenAt(-1);
             // Remove last EOL
         }
         // Remove paragraphs
         if (!$containsParagraphs && $contentTokenList->first()->getName() === PRule::NAME . AbstractBlockRule::OPEN && $contentTokenList->last()->getName() === PRule::NAME . AbstractBlockRule::CLOSE) {
             $contentTokenList->removeTokenAt(0);
             // Remove first P
             $contentTokenList->removeTokenAt(-1);
             // Remove last P
         }
         // Add new line indicator for paragraphs
         for ($i = 0; $i < count($contentTokenList); $i++) {
             $token = $contentTokenList->getTokenAt($i);
             if ($token->getName() === EolRule::NAME) {
                 $contentTokenList->removeTokenAt($i);
                 $contentTokenList->insertTokenAt($this->name . '_ITEM_EOL', $token->getPosition(), $i);
             }
         }
         // Change LIST_BLOCK to BASE token
         $startRule = $this->set->getStartRule();
         for ($i = 0; $i < count($contentTokenList); $i++) {
             if ($contentTokenList->getTokenAt($i)->getName() === $this->name) {
                 $token = $contentTokenList->getTokenAt($i);
                 $contentTokenList->removeTokenAt($i);
                 $contentTokenList->insertTokenAt($startRule->getName(), $token->getPosition(), $i)->set('content', $token->get('content', ''));
             }
         }
         $tokenList->merge($contentTokenList);
     }
 }