protected function parseHeader(Text $header, Collection $baseTags)
{
$cells = new Collection();
try {
$header->split('/\\|/')->each(function (Text $cell, $index) use($baseTags, &$cells) {
/* @var Tag $tag */
$tag = clone $baseTags->get($index);
$tag->setName('th');
$this->markdown->emit('inline', [$cell]);
$tag->setText($cell->trim());
$cells->add($tag);
});
} catch (\OutOfBoundsException $e) {
throw new SyntaxError('Too much cells on table header.', $this, $header, $this->markdown, $e);
}
if ($baseTags->count() != $cells->count()) {
throw new SyntaxError('Unexpected number of table cells in header.', $this, $header, $this->markdown);
}
return $cells;
}