xref: /plugin/commonmark/src/Dokuwiki/Plugin/Commonmark/Extension/Renderer/Block/TableRowRenderer.php (revision b0a36678775785ae4bed10dd2dcf9b3c90beb0c1)
1656793f4SSungbin Jeon<?php
2656793f4SSungbin Jeon
3656793f4SSungbin Jeondeclare(strict_types=1);
4656793f4SSungbin Jeon
5656793f4SSungbin Jeon/*
6656793f4SSungbin Jeon * This file is part of the clockoon/dokuwiki-commonmark-plugin package.
7656793f4SSungbin Jeon *
8656793f4SSungbin Jeon * (c) Sungbin Jeon <clockoon@gmail.com>
9656793f4SSungbin Jeon *
10656793f4SSungbin Jeon * Original code based on the followings:
11656793f4SSungbin Jeon * - CommonMark JS reference parser (https://bitly.com/commonmark-js) (c) John MacFarlane
12656793f4SSungbin Jeon * - league/commonmark (https://github.com/thephpleague/commonmark) (c) Colin O'Dell <colinodell@gmail.com>
13656793f4SSungbin Jeon * - Commonmark Table extension  (c) Martin Hasoň <martin.hason@gmail.com>, Webuni s.r.o. <info@webuni.cz>, Colin O'Dell <colinodell@gmail.com>
14656793f4SSungbin Jeon *
15656793f4SSungbin Jeon * For the full copyright and license information, please view the LICENSE
16656793f4SSungbin Jeon * file that was distributed with this source code.
17656793f4SSungbin Jeon */
18656793f4SSungbin Jeon
19656793f4SSungbin Jeonnamespace DokuWiki\Plugin\Commonmark\Extension\Renderer\Block;
20656793f4SSungbin Jeon
21*b0a36678SSungbin Jeonuse League\CommonMark\Node\Node;
2294a075eeSSungbin Jeonuse League\CommonMark\Renderer\NodeRendererInterface;
23*b0a36678SSungbin Jeonuse League\CommonMark\Renderer\ChildNodeRendererInterface;
24656793f4SSungbin Jeonuse League\CommonMark\Extension\Table\TableRow;
25656793f4SSungbin Jeon
2694a075eeSSungbin Jeonfinal class TableRowRenderer implements NodeRendererInterface
27656793f4SSungbin Jeon{
28*b0a36678SSungbin Jeon    public function render(Node $node, ChildNodeRendererInterface $DWRenderer): string
29656793f4SSungbin Jeon    {
30*b0a36678SSungbin Jeon        TableRow::assertInstanceOf($node);
31656793f4SSungbin Jeon
32*b0a36678SSungbin Jeon        $result = $DWRenderer->renderNodes($node->children());
33656793f4SSungbin Jeon        $result = preg_replace('/\n/', "", $result); # row on one line
34656793f4SSungbin Jeon        return $result . '|';
35656793f4SSungbin Jeon
36656793f4SSungbin Jeon    }
37656793f4SSungbin Jeon}
38