Markdownify\ConverterExtra::alignTdContent PHP Méthode

alignTdContent() protected méthode

properly pad content so it is aligned as whished should be used with array_walk_recursive on $this->table['rows']
protected alignTdContent ( &$content, integer $col ) : void
$col integer
Résultat void
    protected function alignTdContent(&$content, $col)
    {
        if (!isset($this->table['aligns'][$col])) {
            $this->table['aligns'][$col] = 'left';
        }
        switch ($this->table['aligns'][$col]) {
            default:
            case 'left':
                $content .= str_repeat(' ', $this->table['col_widths'][$col] - $this->strlen($content));
                break;
            case 'right':
                $content = str_repeat(' ', $this->table['col_widths'][$col] - $this->strlen($content)) . $content;
                break;
            case 'center':
                $paddingNeeded = $this->table['col_widths'][$col] - $this->strlen($content);
                $left = floor($paddingNeeded / 2);
                $right = $paddingNeeded - $left;
                $content = str_repeat(' ', $left) . $content . str_repeat(' ', $right);
                break;
        }
    }