Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
57
vendor/doctrine/rst-parser/lib/LaTeX/Renderers/TableNodeRenderer.php
vendored
Normal file
57
vendor/doctrine/rst-parser/lib/LaTeX/Renderers/TableNodeRenderer.php
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\LaTeX\Renderers;
|
||||
|
||||
use Doctrine\RST\Nodes\TableNode;
|
||||
use Doctrine\RST\Renderers\NodeRenderer;
|
||||
|
||||
use function count;
|
||||
use function implode;
|
||||
use function max;
|
||||
|
||||
final class TableNodeRenderer implements NodeRenderer
|
||||
{
|
||||
/** @var TableNode */
|
||||
private $tableNode;
|
||||
|
||||
public function __construct(TableNode $tableNode)
|
||||
{
|
||||
$this->tableNode = $tableNode;
|
||||
}
|
||||
|
||||
public function render(): string
|
||||
{
|
||||
$cols = 0;
|
||||
|
||||
$rows = [];
|
||||
foreach ($this->tableNode->getData() as $row) {
|
||||
$rowTex = '';
|
||||
$cols = max($cols, count($row->getColumns()));
|
||||
|
||||
foreach ($row->getColumns() as $n => $col) {
|
||||
$rowTex .= $col->render();
|
||||
|
||||
if ((int) $n + 1 >= count($row->getColumns())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rowTex .= ' & ';
|
||||
}
|
||||
|
||||
$rowTex .= ' \\\\' . "\n";
|
||||
$rows[] = $rowTex;
|
||||
}
|
||||
|
||||
$aligns = [];
|
||||
for ($i = 0; $i < $cols; $i++) {
|
||||
$aligns[] = 'l';
|
||||
}
|
||||
|
||||
$aligns = '|' . implode('|', $aligns) . '|';
|
||||
$rows = "\\hline\n" . implode("\\hline\n", $rows) . "\\hline\n";
|
||||
|
||||
return "\\begin{tabular}{" . $aligns . "}\n" . $rows . "\n\\end{tabular}\n";
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue