/** * @param BlockInterface $block * * @return ItemInterface */ public function addItem(BlockInterface $block) { $lineContent = $block->getContent(); $item = $this->createItem(); $item->setContent($lineContent); $item->setId($block->getLineNumber()); $level = $this->getLevelByContent($lineContent); $item->setLevel($level); $this->itemsRegistry->addItem($item); $this->addToTreeStructure($item, $level); $this->levelLastItem[$level] = $item->getId(); return $item; }
/** * @param BlockInterface $block * * @return string */ protected function createTableRow(BlockInterface $block, $isHeader = false) { $lineContent = trim($block->getContent(), '|'); if (empty($lineContent)) { return ''; } $tableRow = explode('|', $lineContent); if (strpos($lineContent, '---') !== false) { foreach ($tableRow as $rowIndex => $row) { $this->setColumnMetadata($rowIndex, $row); } return ''; } $rowHtml = $this->getTableRowStartTag(); foreach ($tableRow as $rowIndex => $row) { $rowHtml .= $this->getTableColumnStartTag($rowIndex, $isHeader); $rowHtml .= $this->parseInlineMarkup(trim($row)); $rowHtml .= $this->getTableColumnEndTag($isHeader); } $rowHtml .= $this->getTableRowEndTag(); return $rowHtml; }