src/Ciconia/Extension/Gfm/TableExtension.php
protected function parseBody(Text $body, Collection $baseTags)
    {
        $rows = new Collection();

        $body->split('/\n/')->each(function (Text $row, $index) use ($baseTags, &$rows) {
            $row->trim()->trim('|');

            $cells = new Collection();

            try {
                $row->split('/\|/')->each(function (Text $cell, $index) use (&$baseTags, &$cells) {
                    /* @var Tag $tag */
                    $tag = clone $baseTags->get($index);
                    $this->markdown->emit('inline', array($cell));
                    $tag->setText($cell->trim());

                    $cells->add($tag);
                });
            } catch (\OutOfBoundsException $e) {
                throw new SyntaxError(
                    sprintf('Too much cells on table body (row #%d).', $index),
                    $this, $row, $this->markdown, $e
                );
            }

            if ($baseTags->count() != $cells->count()) {
                throw new SyntaxError(
                    'Unexpected number of table cells in body.',
                    $this, $row, $this->markdown
                );
            }

            $rows->add($cells);
        });

        return $rows;
    }
protected function parseBody(Text $body, Collection $baseTags)
    {
        $rows = new Collection();

        $body->split('/\n/')->each(function (Text $row, $index) use ($baseTags, &$rows) {
            $row->trim()->trim('|');

            $cells = new Collection();

            try {
                $row->split('/\|/')->each(function (Text $cell, $index) use (&$baseTags, &$cells) {
                    /* @var Tag $tag */
                    $tag = clone $baseTags->get($index);
                    $this->markdown->emit('inline', array($cell));
                    $tag->setText($cell->trim());

                    $cells->add($tag);
                });
            } catch (\OutOfBoundsException $e) {
                throw new SyntaxError(
                    sprintf('Too much cells on table body (row #%d).', $index),
                    $this, $row, $this->markdown, $e
                );
            }

            if ($baseTags->count() != $cells->count()) {
                throw new SyntaxError(
                    'Unexpected number of table cells in body.',
                    $this, $row, $this->markdown
                );
            }

            $rows->add($cells);
        });

        return $rows;
    }
@param Text       $body
@param Collection $baseTags

@return Collection