# [Retina], 52 bytes

This answer is based on my [Perl answer](https://codegolf.stackexchange.com/a/129142/55508), with the help of [Martin Ender](https://codegolf.stackexchange.com/users/8478/martin-ender) for the golfing with Retina.

<pre><code>^ *
[
$
]
\s+
,&#32;
m):`.+
[$&amp;]
*T`[]`{}
], .
;&#32;
^.|]$

</code></pre>


[Try it online!][TIO-j4jq25bq]

The explanations can be found on my Perl answer. The differences are:  

    *
    [
    $
    ]

Instead of `s/^ *(.+)/[$1]/gm` to both remove the leading spaces and add brackets around the lines.  

    ^.|]$
    
To remove the leading and trailing brackets for the third output.


[Retina]: https://github.com/m-ender/retina
[TIO-j4jq25bq]: https://tio.run/##ZVE7UsQwDO11CheBWXY3GX38kckxlm4JEwoKCiiADrgWB@BiQbYzyyx4JnqKpPf8lLw8vD0@3y/fXzDCYR5HuNhsDJc7t4UjdDDB7esO9g6erq7nYQfH7nKC7c18nOb3T5j2boDRwd3wMXWwHOZuoejscAliDwm4UJBKwFJWcLlgKqFME4PzBWso044AcCCfktoLDpyoNi3znoL1fMg51Qoxa8ti8gmtx5p9qBVJmZtCINUE0OOAklWQVjUUH2zW6sxBJLZpCTFowppjxKAoLTdmUiwywsF75kol0kCZmkzWHGS1Fn0Syk0yMpE0W4zmxtYobpDNf6Pa9W2XvjpQ75uMrZwxNgeixk3tWlbbV8Q@lWvHr0gr4qmzYh//deic2wvwOeeE@lftFwHsh5FjAA/hBw "Retina – Try It Online"