docs: def parse_index(index, items):
      """Return a list of 0-based index numbers from a (1-based) `index` str.
  
      * A single item index, like `[3]`. Negative indices count backward from
        the bottom; that is, the bottom-most item in a 3-item stack can be
        identified by `[3]` or `[-1]`.
      * A slice, shorthand for the entire inclusive range between two numbers,
        like `[3:5]`. Either number may be negative, or omitted to mean 1 or -1,
        respectively. If both are omitted as `[:]` then all items match.
      * Any "text" surrounded by single or double-quotes, which matches any
        item containing the text (case-insensitive).
      * Any /text/ surrounded by forward-slashes, a regular expression
        to match item content.
      * The values "first" or "last" (without quotes).
      * Any combination of the above, separated by commas; for example,
        given a stack of items "1: red | 2: orange | 3: yellow | 4: green |
        5: blue | 6: indigo | 7: violet", the index `[6, :2, "i"]` identifies
        "6: indigo | 1: red | 2: orange | 7: violet". Note that "indigo"
        matches both `[6]` and `["i"]`, but is only included once. However,
        if the stack had another "8: indigo" entry, it would have been included.
  
      """
      indices = []
      if index is None:
          return indices
  
      for atom in index.split(","):
          atom = atom.strip()
          if not atom:
              continue
  
          if (
              (atom.startswith("'") and atom.endswith("'")) or
              (atom.startswith('"') and atom.endswith('"'))
          ):
              atom = atom[1:-1].lower()
              for i, item in enumerate(items):
                  if atom in item.lower():
                      indices.append(i)
          elif atom.startswith('/') and atom.endswith('/'):
              atom = atom[1:-1]
              for i, item in enumerate(items):
                  if re.search(atom, item):
                      indices.append(i)
          elif ":" in atom:
              start, end = [x.strip() for x in atom.split(":", 1)]
              start = int(start) if start else 1
              if start < 0:
                  start += len(items) + 1
              end = int(end) if end else len(items)
              if end < 0:
                  end += len(items) + 1
              start -= 1  # Shift to Python 0-based indices
              end -= 1    # Shift to Python 0-based indices
              for i in range(start, end + 1):
                  indices.append(i)
          elif atom == "first":
              indices.append(0)
          elif atom == "last":
              indices.append(len(items) - 1)
          else:
              index = int(atom)
              if index < 0:
                  index += len(items) + 1
              index -= 1  # Shift to Python 0-based indices
              indices.append(index)
  
      return indices