Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Table rendering misalignment when using colored/formatted strings in Table component #127

Copy link
Copy link

Description

@acataluddi
Issue body actions

Hi Jitendra,

I've discovered a table rendering bug that occurs when using colored/formatted strings. Here's an example with a 2x2
table where values in the last column are in bold:

$rows = [
    ['Name' => 'Server A', 'Hostname' => '<bold>server-a.example.com</end>'],
    ['Name' => 'Server B', 'Hostname' => '<bold>server-b.example.com</end>'],
];

$this->app()->io()->writer()->colors((new Table())->render($rows));

The expected output should be:

+----------+----------------------------------+
| Name     | Hostname                         |
+----------+----------------------------------+
| Server A | server-a.example.com             |
| Server B | server-b.example.com             |
+----------+----------------------------------+

As a result, I get the following:

+----------+----------------------------------+
| Name     | Hostname                         |
+----------+----------------------------------+
| Server A | server-a.example.com |
| Server B | server-b.example.com |
+----------+----------------------------------+

I believe the formatting tags are included in the string length calculation but then removed without being replaced by
trailing white spaces, as the number of missing characters exactly matches strlen('<bold></end>').

Kind regards,

Adriano

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.