aquasecurity / aquasecurity/table

Indented multiline cell content doesn't retain indentation

Open
#21 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
132
Forks
8
PR merge metrics
No merged PRs in 30d

Description

## Disclaimer

I could always be making a mistake on my end...failing to set an option, etc.

## Problem Statement

I prefer your table lib over other very good libs, however there's an issue with rendering indented, multiline content, such as when I display two formatted json structures side-by-side for comparison. It appears the content may be getting trimmed line-by-line? (I haven't looked at your code.)

Here's a link to a play comparing outputs between this (preferred) lib, and another (excellent, and currently in use) table lib: https://go.dev/play/p/_Cy7gLBIxja

## Want: Retains nice indentation

```
+-----------------------------+-----------------------+
| JSON A | JSON B |
+-----------------------------+-----------------------+
| { | { |
| "foo": "fooA", | "foo": "fooB", |
| "bars": [ | "bars": [ |
| { | { |
| "name": "bar1", | "name": "bar1", |
| "a_num": 73, | "baz": false |
| "is_something": false | }, |
| }, | { |
| { | "name": "bar2", |
| "name": "bar2", | "baz": true |
| "a_num": 2, | } |
| "is_something": true | ] |
| } | } |
| ] | |
| } | |
+-----------------------------+-----------------------+
```

## Got:

```
┌───────────────────────┬─────────────────┐
│ JSON A │ JSON B │
├───────────────────────┼─────────────────┤
│ { │ { │
│ "foo": "fooA", │ "foo": "fooB", │
│ "bars": [ │ "bars": [ │
│ { │ { │
│ "name": "bar1", │ "name": "bar1", │
│ "a_num": 73, │ "baz": false │
│ "is_something": false │ }, │
│ }, │ { │
│ { │ "name": "bar2", │
│ "name": "bar2", │ "baz": true │
│ "a_num": 2, │ } │
│ "is_something": true │ ] │
│ } │ } │
│ ] │ │
│ } │ │
└───────────────────────┴─────────────────┘
```

## Usual Sob Story

I'd love to contribute a fix for this, however this unfortunately relates to a work effort. Because my employer avoids ip ownership and licensing conflicts by not allowing open source contributions, I cannot.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the linked Go playground example with the indented, multiline JSON cells and compare the rendered output. Trace the table's multiline cell rendering to find where leading whitespace is removed. Done means indentation is preserved in multiline cells and the reported comparison output renders as shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.