How to convert a nested list to a bulleted list

Sorry, got busy for a few days.

Here’s the table solution: recursive collection of data from items:

With regular text it’s a bit tricky because Coda tried to “fix” the one vs list-of-one issue with another “magical” behavior where the list of one is silently treated as an item on its own:

The crazy approach I’d use here to determine what’s the level of the nesting of each given item is to… convert the list to text and calculate nesting by taking the number of [s and ]s and subtracting one from another :smiley: Of course this won’t work if the items themselves have [] characters (although it can be worked around with smarter regex) and if one item appears elsewhere, e.g. “Cheese” and “Cheese sticks” might trigger faulty results because of a substring being found twice

WithName(Input + "", InputToText,
  Input.ListCombine().ForEach(
    InputToText.Find(CurrentValue).WithName(FoundPosition,
    InputToText.Left(FoundPosition).WithName(AllPreText,
      List(
        AllPreText.RegexReplace("[^\[]", "").Length() - AllPreText.RegexReplace("[^\]]", "").Length(),
        CurrentValue
      )
    ))
  ).ForEach(
    CurrentValue.Last().BulletedList().IndentBy(CurrentValue.First() - 1)
  ).Concatenate()
)

Update: Fixed this by wrapping the list into an object first. This way Coda preserves the lists properly (turns it into proper JSON):

6 Likes