[Question]
  [
I [like](https://codegolf.stackexchange.com/questions/241650/sort-every-dimension) [to](https://codegolf.stackexchange.com/questions/233030/build-me-a-room) [pretty print](https://codegolf.stackexchange.com/questions/236884/remove-submatrices) multidimensional arrays, like this:
```
[ [ [1, 2, 3],
    [4, 5, 6] ],
  [ [7, 8, 9],
    [6, 4, 2] ] ]
```
But it's a pain to do by hand and it'd be nice to have a program that does this for me. Your challenge is to create a program that does this for me, taking a multidimensional array containing only positive integers and prettyprinting it.
Specifically, an array of depth 1 is printed joined by `,`  with `[` prepended and `]` appended:
```
[1, 2, 3]
```
An array of depth \$n+1\$, which contains at least one array of depth \$n\$, has its subarrays prettyprinted, joined by newlines and indented by two spaces. All but the last subarray have a comma appended, the last has  `]` appended, and the first has its first line indented with `[`  instead of two spaces:
[![enter image description here](https://i.stack.imgur.com/YoEb4.png)](https://i.stack.imgur.com/YoEb4.png)
Here's a reference implementation:
```
function recursivePrettyPrint(array){
  if(array.every(x => typeof x == "number")){
    return `[${array.join(', ')}]`;
  } else {
    return array.map((item, index) => {
      let result = recursivePrettyPrint(item) + ',';
      result = result.split`\n`;
      if(index == 0){
        result[0] = '[ ' + result[0];
      } else {
        result[0] = '  ' + result[0];
      }
      for(let i = 1; i < result.length; i++){
        result[i] = '  ' + result[i]
      }
      return result.join('\n');
    }).join('\n').slice(0,-1) + ' ]';
  }
}
function change(){
  let array = JSON.parse(document.getElementById('input').value);
  let output = document.getElementById('output');
  output.innerText = recursivePrettyPrint(array);
}
```
```
<textarea id=input></textarea>
<button id=run onclick=change()>Pretty Print</button>
<pre id=output></pre>
```
Numbers may be multiple digits. The input will always be orthogonal/rectangular, and you may take its dimensions as well. Trailing spaces on lines are allowed.
## Testcases
```
[[892, 759], [962, 251]] ->
[ [892, 759],
  [962, 251] ]
[118, 922, 619] ->
[118, 922, 619]
[[966, 639, 616, 255], [622, 483, 87, 241], [453, 870, 728, 725], [163, 936, 48, 967], [261, 833, 87, 200]] -> 
[ [966, 639, 616, 255],
  [622, 483, 87, 241],
  [453, 870, 728, 725],
  [163, 936, 48, 967],
  [261, 833, 87, 200] ]
[[[[[912, 547], [366, 754]], [[723, 536], [779, 238]]], [[[559, 392], [602, 709]], [[692, 915], [412, 302]]]], [[[[3, 504], [936, 83]], [[352, 442], [425, 375]]], [[[380, 440], [793, 762]], [[850, 321], [780, 457]]]]] ->
[ [ [ [ [912, 547],
        [366, 754] ],
      [ [723, 536],
        [779, 238] ] ],
    [ [ [559, 392],
        [602, 709] ],
      [ [692, 915],
        [412, 302] ] ] ],
  [ [ [ [3, 504],
        [936, 83] ],
      [ [352, 442],
        [425, 375] ] ],
    [ [ [380, 440],
        [793, 762] ],
      [ [850, 321],
        [780, 457] ] ] ] ]
[[[128, 910, 664, 658], [172, 238, 564, 492], [325, 384, 566, 90]], [[876, 819, 764, 105], [583, 528, 731, 839], [480, 126, 692, 875]], [[215, 84, 268, 504], [400, 674, 997, 526], [799, 692, 193, 296]], [[943, 185, 567, 188], [118, 200, 879, 409], [116, 493, 62, 343]]] -> 
[ [ [128, 910, 664, 658],
    [172, 238, 564, 492],
    [325, 384, 566, 90] ],
  [ [876, 819, 764, 105],
    [583, 528, 731, 839],
    [480, 126, 692, 875] ],
  [ [215, 84, 268, 504],
    [400, 674, 997, 526],
    [799, 692, 193, 296] ],
  [ [943, 185, 567, 188],
    [118, 200, 879, 409],
    [116, 493, 62, 343] ] ]
```
  
[Answer]
# [Python 2](https://docs.python.org/2/), ~~74~~ ~~73~~ 72 bytes
-1 thanks to [loopy walt](https://codegolf.stackexchange.com/questions/242999/pretty-print-my-arrays/243009#comment547333_243009)
-1 thanks to [dingledooper](https://codegolf.stackexchange.com/questions/242999/pretty-print-my-arrays/243009#comment547352_243009)
```
f=lambda l,s=',\n  ':l<[f]and`l`or'[ %s ]'%s.join(f(r,s+'  ')for r in l)
```
[Try it online!](https://tio.run/##PVLLbuMwDLz3K3QpHGONQqKeLNovUQU0i25QF64TOCkW@/Uph2rWB0EcksMZyqd/l/fjStfr4XnZf/5@25tlOj8P08tqzPC4PNVD269vr8vrcRuquT@bNtyfHz6O87o77Lbp/GuQuvFw3Mxm5tUs4/Xv@7z8Me7xzpy2eb1I2byevi67cRyvtRamyeTIbTKVk9wputbuqnNlMkwCJMcSSzLJ3TOAhLKIloSKUPxkShYwOIAhamyFmAoOLXVJUPYJ9XJJGSAlJ6X@1m8tZuNjJ8QxaJHH6BxDQ1AzSXX0CUHOood8aT1VY5TYM6k0C2eWeyrBJztVEsDtLbVbWwWjDboDCCy@J3yEu6B0gaI05Xjr8cUiZ1UGC0FO1FMlSsaTriJrVcwYpc4cNsJO0JSCHLHobjKpD5EBNHQHXkeWAFRUsf3hz5DoGCMl56yainiEqPv2ulN90oD5jvB0WECBfnCQE2owUyr/vQcLWVlQ5gyyvmPmn24Hm8SpU3CQyJUIdRm37gT/DYGo4G2C5Y7i2dGOX8wH2W/7Bg "Python 2 – Try It Online")
[Answer]
# [JavaScript (SpiderMonkey)](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/45), 69 bytes
```
(g=j=>a=>+(u=uneval(a))[1]?u:`[ ${a.map(g(j+'  ')).join(j)} ]`)`,
  `
```
[Try it online!](https://tio.run/##NY7LasMwEEX3/YpZFCIRNcgaPayA0g8RAovWCVYaxzhxIJR@uyvZZHaHM/fOpPiIt6@xG@4ft6H7bsfLtT@3z/noZnJyyR2iO2zJ5Ka@fcQfEin1Vfic9o2H99@4u8SBnEjabgA2lO7StetJon8QGtqwN4BmHsauv5Mj8WVsJRgoaQIDj1ozMEqGAt4IzAZ1AWMsA4F1WJVXKjNaUUjz3GC4XZW2mWylCsjSjVyEV8yXRi4LWMy3alwFqrwo5VInhcoho14ZrHlxfHnD5gKjxapqlQ2KajHLljLlVKB0/gc "JavaScript (SpiderMonkey) – Try It Online")
This answer assume the array only contains positive integers.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~38~~ 37 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
dΔ€`}\„, ý'[ì']«N©F„
,®N-·úRý„[ ì„ ]«
```
[Try it online](https://tio.run/##LY0xDsIwDEV3TtGNxUipHcf1BRgZWEMkQDAwMTAjIc7AzI6oWJGQWJqdQ3CR4lRk8fPz18/@sFrvtn2/@Vy@53Z5XHxPV6jyexxzO07dfdbdpqZG0D1mk@6ZX/P8tj1WubVRWaLvY3laI7CXBJFCAGGfDKMgAVMwFFFAatKgI7MCKRoHhyBOBx0UQWs29NZGDtM/Hq3FeUOlAA0NkhjB@1LhkYGE/1lqnHlXvlQCCTjohh0Q1sWWO0upTj8) or [verify all test cases](https://tio.run/##NVK9alZBEO3zFJevSTPC7vzs7tjYiJAmgu16QUULGw0kESwCkmdInV78sFQQ0tzb@xB5kc8zez8XLrt7dmbOOTP38@Xbdx8/HL7szj5dXF89nXb0lU52L6@v/t@eH97/vXu83b@5ef347Z6m9eG0r/vTeflxvnx/AeiElp/nT5bf659X6wPufVr32CZEHG5o@fXs0LEyMclMXcmozDj0So0ch0JKPAOaem/OVC1QL0xsecA5I5KZSvYR5aVQEce9IMaiBl61CbVKrDloLC6JKjd8EZKLkAvIUKtUAFwyNdlyUtr4sTwzmUaAgKaabmJZyKTgWKsTS5sH3M2cxDkkJEhPPuACG56DVVFNUtgb4R1VkoY9KGkyQDFo1yihbCTVjrHSEvAUlC5UCw@4WSLhsFjj3eo8H3vXM7x6TlSKUrEWniuHVjIgOlRKUDQMAd48bRUrpGQHg1JOIdrQSYvGSXQopqHgyoyuw1gLhcjjbIRKXNrRkyZwVyX3ivTRK/eRkmGAfRu7q1BuBgUV@1CJ8WICKOykyQeCOSEH/4CohMF/).
**Explanation:**
```
dΔ€`}\...N         # Determine the depth of the input:
d                  #  Transform each inner-most integer to a 1 (with >=0 check)
 Δ                 #  Loop until the result no longer changes:
  €`               #   Flatten it one level down
    }\             #  After the loop: discard the resulting list of 1s
„, ý               # Join each inner-most list of the (implicit) input with
                   # ", "-delimiter
    '[ì           '# Prepend a "[" in front of each string
    ']«           '# Append a "]" after each string
         N         # Push the reached index of the earlier loop, which is the
                   # depth of the input-list - 1
 ©                 # Store this depth-1 in variable `®` (without popping)
  F                # Loop `N` in the range [0,®):
   „\n,            #  Push string "\n,"
       ®N-         #  Subtract `N` from `®`
          ·        #  Double it
           ú       #  Pad the string with that meany leading spaces
            R      #  Reverse it
             ý     #  Join each inner-most list of strings with this as delimiter
              „[ ì #  Prepend a "[ " in front of each string
              „ ]« #  Append a "]" after each string
                   # (after which the result is output implicitly)
```
`dΔ€`}\...N` to determine the depth is taken from [this answer of mine](https://codegolf.stackexchange.com/a/240671/52210).
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 96 bytes
```
f(a,i=",\n  ")=print1(if(#a[1]',l=!print1("[ ");[(l--&&print1(i))+f(b,Str(i"  "))|b<-a];" ]",a))
```
[Try it online!](https://tio.run/##PVLLbuMwDPwVVQt0bawMiHoTbfoTe3R9cA8pDASBEfRSoP@ecqgkPgjicDgcUt7XyzZ97tfrcVjddrDu/WyMHQ/7ZTt/0bAdhz/rTMtfdzo83TA7C@FlHk7T9Px8543jv@Pw4f5/XYbNQmH8@Xid1uXFmsW6dRyv676fvofVTG9Gi@RqJRApI73l7Kh9P9vRmXmeGwdnauZFIi5yD5kWBETNGQ6CFNKspIsEkYEUEDPgAkpq0ZlWBUwEMGWNvUiHhkOpVATlWMCXS6kAQyGhxnu999odH5Mo56SsiN41p56sQeg5FgS1iqEQ23Kry1niyEG9eQznuacKRmVSKwna0YflXjZD0SddAxy22BMxY7ykcilkKar5XhObR86rDRaBWkJPtSyZGHQXVVm5Lo9ehJ0wCVxKkiM33U4NOoj4AJr6CFF7tgRUbPFtPa3CIzF6So68TpXxDFk3HnWr@nAJBijg8bCBhgGgEUikoRxKewyfPGxVQZkrxPqSmW/VhDkDly7BSSJqGe4qbu3x6wQINTxO8txRPDzK8ZvFFLGP8foL "Pari/GP – Try It Online")
A port of [@att's Python answer](https://codegolf.stackexchange.com/a/243009/9288).
[Answer]
# [Pip](https://github.com/dloscutoff/pip) `-x`, ~~37~~ 35 bytes
```
"[]"J:0*@a?(fMaJ:",
")WRsRn"
  "aJk
```
Recursive full program; takes the array as a nested list in Pip format from the command-line. [Attempt This Online!](https://ato.pxeger.com/run?1=PZA_S4MxEIdx7eY3CHGxYiF3-XN3zaDzCy5dHEKGdymIUAqt4HdxEUr9TvppvDPFJSRP7vfcJR-n_cv-q_nVu--f57fjdsXfN751P63D3eP8cLt9mqe1v1_45fPmsNn5hXN-nl5H6SXxc3XdfGsNkKsTCNWVknTJ3KtrQFgdRr3KRpOg0Yi5usjJaNFU6EYbkx4YpDqyYgjZcOaodWanCHofxWhi7QSogSLagikPB4KqzYzFmob0VxxsLFIqQiYrRknkkgbRFihlKCTpCTjbdGS78RJQH5qISXMpyKDFXqWBop6YYu_9_zN_AQ)
### Explanation
Using `¶` in place of newlines for better readability:
```
"[]"J:0*@a?(fMaJ:",¶")WRsRn"¶  "aJk
         a                           ; Current list
        @                            ; First element
      0*                             ; Times 0
          ?                          ; Is truthy?
                                     ; If so, first element is a list:
            f                        ;  Apply the main function recursively
             M                       ;  to each element of
              a                      ;  the current list
               J:                    ;  Join the results on
                 ",¶"                ;  comma + newline
           (         )WR             ;  Wrap that string in
                        s            ;  space
                         R           ;  Replace
                          n          ;  each newline with
                           "¶  "     ;  newline plus two spaces
                                     ; Else, first element is a number:
                                a    ;  Current list
                                 J   ;  joined on
                                  k  ;  comma + space
"[]"                                 ; Open bracket + close bracket
    J:                               ; joined on the above result
```
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 66 bytes
```
,|\[\B
$& 
\B]
 ]
], (?=(.+))
],¶$1_
T`d ,``.+_
+`\[]
+`]_
_  
_
```
[Try it online!](https://tio.run/##LVE7blwxDOx1ilcYgY0lDIk/iUUQwGdIpxXeBkgKNymClDlXDpCLbYbyPuBB0pCcGZK/fvx@//ntfqc/13l9K0@fjnJ9W@VYZdHx/OXz8@vl5QX3f3@f2lm@3r4fdLu9Xs5yuV3nKjjWWc7jKGe53@ccwdQtFs1wJra2VpmtDQpm8hZ4IeLkEng6Mgy5jqAOodGJtQFQy0elzgN/pjQXCnGkUXgHwN5oyEdNrSmTXzQm04wLVLrpwnV2FjJxXHsPYhlrw9MsSILTQYXvGht29BAtRRVsUnk90idYqmZvMDJkg2KwrkmhbCTdHrkyKvCakiHUnTc8rJJwdtgzbj2pt/WGTqNVcldyG9lx57RKBkS3SUmFoUCcon4QdjhpAQGlVtOzYY6WY5OcT25CIdUYM0dfIw2ijpsRmNjHoyWt0O5KER3le1QRu6TBP4fvslChNgwOOs7tErvF/EEcpDU2gi2hBvsXxZDWfw "Retina 0.8.2 – Try It Online")
### Explanation
The first four lines, which add spaces where necessary, are taken from [Neil's Retina answer](https://codegolf.stackexchange.com/a/243021/16766).
Now, observe that:
* We need to add a newline and an indent after every occurrence of `],`
* The indentation level is equal to the nesting level at that point in the list, which can be calculated by looking at the number of brackets in the remaining part of the list: nesting level = (# of remaining close brackets) - (# of remaining open brackets)
So:
```
], (?=(.+))
```
Match `],`  and capture the rest of the line in group 1; then:
```
],¶$1_
```
Replace that with `],` followed by a newline, the contents of group 1, and an underscore for a separator.
```
T`d ,``.+_
```
Transliteration stage: Replace digits, space, and comma with nothing (i.e. delete them) when they appear in any match of `.+_` (i.e. before `_` on a line).
```
+`\[]
```
Repeatedly delete empty matched brackets (which can only occur in the before-`_` context) until none are left.
```
+`]_
_  
```
Repeatedly replace close-bracket followed by underscore with underscore followed by two spaces. This has the effect of translating each level of nesting (represented by the unmatched close-brackets) into two spaces of indentation.
```
_
```
Delete the underscores.
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 76 bytes
```
,|\[\B
$& 
\B]
 ]
+%1`((.*?\[)((\[)|(?<-4>])|[^][])+(?(4)^),) \[
$1¶$.2$*  [
```
[Try it online!](https://tio.run/##LVE5jtwwEMz1ignGhrTbXrAvkg0YHmC/weHCGzhw4sBwOO/yA/yxcTV3BEgiq4@q6v7948/PX@/3O92u4/q6nT@ftuvr3E5ze/7E3/f95elyHce@43PbL1@/2Ld53MbbHPN43i@7HW8HHafr2M787@/5Rc5Pp9O438foIdQ8Jo2oQuI85zaYO4UIVQ7cEKlUNXCtyHDkVgStK/VGYgzAPC@FmnS8mcJVKbQijaI2AFKZun7UlJI0@QQLuWVcwdLcJo6jiZJrxbG1INE@FzzcgzQkFRToLrHgCg/BSWropkXmI32gS7H0BiFdF6gO6ZYtTJy0@SNXewFekjKUWpUFdy@kkg5bxr1l6yWd4TS4UK1G1Xs6bpJSyYHYEqnJ0A1IpSgfDRuUcIDAiEtqdszRc2ya88lNGKhYMHP46ikQdcJO6CS1PyxZAXczimgoX6OKWCUM/RJ1lYUpcXcoaPgvldgt5o/GQVZiIdgSarB/NQxp/gc "Retina 0.8.2 – Try It Online") Link includes test cases. Assumes input contains no spaces (seems awkward to ask for spaces given that this is a formatting challenge). Explanation:
```
,|\[\B
$& 
\B]
 ]
```
Insert the necessary spaces.
```
+%1`
```
Repeatedly replace the first occurrence on each line until no more replacements can be made:
```
((.*?\[)((\[)|(?<-4>])|[^][])+(?(4)^),) \[
```
Match as little indentation (up to and including the parent `[`) as possible, as many subarrays as possible, then the start of a subarray.
```
$1¶$.2$*  [
```
Wrap that last subarray to a new line, giving it the indentation it needs converted to spaces (it would have contained `[`s).
60 bytes by using @DLosc's observation that the amount of indent can be calculated from the remaining square brackets:
```
,|\[\B
$& 
\B]
 ]
], (?=((\[)|(?<-2>])|(){2}]|.)+)
],¶$#3$* 
```
[Try it online!](https://tio.run/##LVFLblsxDNy/UxiIUdgJG0j8SQTaBMg1ZC2yyCKbLILs6l4rB@jF3KHsBwhPGg45Q/Lz7ev94/VyofNpnF62/Y/ddnqZ225uk3aH59@Hw2kcz4fnXz/5aeJy/MN/5/nx@HAE4d/3/k7297vLZYweTM1i0ghnYqtzbqPWTsFMXgMvRJxcAk8Hw8B1BLUL9UasFYBaPgo17jhJqS4U4qBReAPAXqnLNaeUlMkvKpNpxgUqzXTiOhoLmTiurQWx9LngYRYkwemgwHeJBTt6iJqiimpSeN7oA1WKZm8w0mWBYrCuWULZSJrduNIL8JKSIdScF9ytkHB22DJuLUsv6xWdRi3kruTWs@PGaZUMiC6TkgpdgThFuRZscFIDAkq1pGfDHC3HJjmf3IRCqjJmjr56GkQeVyNUYu@3lrRAuylFNKSvUUWslAr/HL7SQoVqNzho@C@X2C3mj8JBWmIh2BJysH9RDGn@Bw "Retina 0.8.2 – Try It Online") Link includes test cases. Explanation: The first two stages add the necessary spaces as above.
```
], (?=((\[)|(?<-2>])|(){2}]|.)+)
```
Match a closing square bracket with a comma, count the number of `[`s in `$#2`, ignore that many `]`s, then count two (spaces of indent) for each extra `]`.
```
],¶$#3$* 
```
Break the line after the comma and replace the space with the desired amount of indent.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), ~~75~~ 60 bytes
```
≔⭆¹ＳθＦ[]≔⪫Ｅ⪪θι∨κ ιθ≔⪪✂θ¹±¹¦¹], θ⪫Ｅθ⁺×  ⁻№⪫…θκω[⁺κ№⪫…θκω]ι],¶
```
[Try it online!](https://tio.run/##hY/NasMwEITvfQrhkwxb0L@05FRyaiFtIL25PhjjJiKundhOS5/eXSspPVYgBMN8M6P6UA11X7Xz/DCOcd/x3TTEbr@pTlwCe@xOl@mq8DwHds5Xd@/9wHhWlFnObshTHzu@ELtTGyd@BhbJ@zLwI7CMZQsYb/BvSTLu2lg3i52anpt9NTVckm@5WUn3xmypfvorIf@2vYz8NX40I88Yy4BtYkfKur/8GtffddusD32yHynoawktlsgE07J/3fTD/Lr9OuitI2E1zwUdqQKgFOCcAWdDCYX0CpQOYEkxqEjRyoIOhhQHKEpSiuAdBIngySSFJckGDZbCvJYQNJJiggCpHDhUELxNnJIWKEk5yhdmMQnq9gYQPeGOFI@YEIkaFLqEodEgg6UFnt60UgZQxAaPYAQmxdFeDU6BNrqkM99/tj8 "Charcoal – Try It Online") Link is to verbose version of code. Explanation: Uses @Dlosc's observation that the indent can be calculated from the difference in numbers of `[`s and `]`s.
```
≔⭆¹Ｓθ
```
Input the array and perform Python stringification on it, which joins the elements with `,`  but wraps them in `[` and `]` without spaces.
```
Ｆ[]≔⪫Ｅ⪪θι∨κ ιθ
```
Insert spaces between pairs of `[` or `]`. Unfortunately this also adds a leading and a trailing space.
```
≔⪪✂θ¹±¹¦¹], θ
```
Trim away that leading and trailing space, then split on `],` .
```
Ｅθ⁺×  ⁻№⪫…θκω[⁺κ№⪫…θκω]ι],¶
```
Map over the pieces of strings, calculating the indent from the number of `[`s in all the previous strings minus the number of `]`s in all the previous strings (adjusted because they've been split on `],`), then output the strings each on their own line with the `],` restored (but not on the last line).
[Answer]
# Python3, 230 bytes:
```
E=enumerate
def f(x,d=[]):
 m=len(d)-(min(i+1 for i,a in E(d)if not any(d[i+1:]))if any(d)else 0)
 return ' '*((len(d)-m)*2)+'[ '*m+str(x)if all(int==type(i)for i in x)else'\n'.join(f(a,d+[i])+','*(i<len(x)-1)for i,a in E(x))+' ]'
```
[Try it online!](https://tio.run/##XVLLbuMwDLznK3Sz3LgLvSUWzbFf4fUhQBzUi8QJXBdIvj7l0EmBrA@GyOEMh5TO1/nzNPpynm63j00/fh/7aTv3q12/V3t9aXabtqvfVuq4OfSj3tWv@jiMelhbtT9Nami2ahjVBwPDXo2nWW3Hq961jL91NXIS1/3hq1emXqmpn7@nUVWqetH6rnisX1y9rlrOHddf86QvQjwc9DDOm818Pfd6qKUdml1Erfo7Vn/@ndjLXm@b3bodOtZoWHZ4h@6lfrX1k8VLzQWqq27niXWZ1raFXKNypK5RLSU@u2g79r36LbG2NIocQ8nSE8KExFlPgBKoETIJtaH4RpXMyWCRDFFiw81cwU9KbeIs@YR6PqSMpEuWS/2Db8yzH3xkuUUMUu5hIsfQIWizY170CUHO7Mz50i1QGyPHnpyYNJjb0AIlbIGseArQ9sZ1D1oLRRNkQ7Ba/AL4iDmDyAUXmZTjg@OLAWbEBrFATm6BSmTEO1lKlqqY0eq/GS22RJbxlAL/YpF9ZScTsSFkwzKLl@YlIMv@yNw7ZZi1hOaMWSPjRVxMlDvwsme5@gAn1uE6sYqCSaDhLEtD2aXyu4VgYCtzlihDbNk20Z1tMbCjtEhQ4MiWCHcZp2USvCoHoYJbCoaWLJ4C6HiKPnjZy@0H)
[Answer]
# [Julia 1.0](http://julialang.org/), 60 bytes
```
>(l,s=",\n  ")=try.~l;"$l"catch;"[ $(join(l.>s*"  ",s)) ]"end
```
[Try it online!](https://tio.run/##PVJBbuMwDLznFarQg70wCpESJRFF8hHXh6JboCkM76LJAtnLfj3lSMn6IIhDcjhD@fPPenyly/V6GNbptPfTzjk/7s9ff5/@rc/@cfVvr@e3j2c/u8fh89dxG9anw@mHt6rpNI5u8e/bz@vDxe3d76/jdl634TBcxsm/bH7c7R5mojo5ZZ5cJl2AzFUtKqLL5GbNdmehpac0ZyuMiuqMhKAooz3VOLlaDEwEMEmLg1FxxdFKKRuqMaPeLrkA5ExWGu/9Idym2adk1JJaWcTwImlBMBe2eokZQSmmiGNdemoWsTgqN3EBboL2VIY3paYlgTsGXu5tMxhDar4hscaeiAJ/qdElFmsqcu@JNSAXmgw1gpK5p6pYJnJbRmlVUjDq5o2wFSXDc052SG37KdycmBCgqXuIbWhNQE2XhtuEApGkGGo5Cs2W4CGk7Ty2vbaHTFBAjOfDCiocgIPJqMHMuf53nwJkFUNVC8j6llVv3QSjrLlTaLKIqkBdwa07wY/FIKp4nRS0o3h6tOPHiiliH9dv "Julia 1.0 – Try It Online") (with a literal `\n`)
port of [att's great answer](https://codegolf.stackexchange.com/a/243009/98541)
`.~l` tries to apply `~` to each element of `l`, which only works if `l` is not nested (shorter than `l[1] isa Int`)
]