protected function consumeTable($lines, $current)
	{
        $pattern =<<< REGEXP
/(?<=\|)(
    ([^\|]*?{{{.*?}}}[^\|]*?)+|
    ([^\|]*~\|[^\|]*?)+|
    [^\|]*
)(?=\|)/x
REGEXP;
        // regexp pattern should be in the order of from specific/long/complicated to general/short/simple.

		$block = [
			'table',
			'rows' => [],
		];
		for ($i = $current, $count = count($lines); $i < $count; $i++) {
			$line = trim($lines[$i]);
			if ($line === '' || $line[0] !== '|') {
				break;
			}
            $header = $i === $current;
            preg_match_all($pattern, '|' . trim($line, '| ') . '|', $matches);
            $row = [];
            foreach ($matches[0] as $text) {
                $cell = [];
                if (isset($text[0]) && $text[0] === '=') {
                    $cell['tag'] = 'th';
                    $cell['text'] = $this->parseInline(trim(substr($text, 1)));
                } else {
                    $cell['tag'] = 'td';
                    $cell['text'] = $this->parseInline(trim($text));
                    $header = false;
                }
                $row['cells'][] = $cell;
            }
            $row['header'] = $header;
			$block['rows'][] = $row;
		}

		return [$block, --$i];
	}