docs: def lines_to_notebook(lines, name=None):
      """
      Convert the lines of an m file into an IPython notebook
  
      Parameters
      ----------
      lines : list
          A list of strings. Each element is a line in the m file
  
      Returns
      -------
      notebook : an IPython NotebookNode class instance, containing the
      information required to create a file
  
  
      """
      source = []
      md = np.empty(len(lines), dtype=object)
      new_cell = np.empty(len(lines), dtype=object)
      for idx, l in enumerate(lines):
          new_cell[idx], md[idx], this_source = format_line(l)
          # Transitions between markdown and code and vice-versa merit a new
          # cell, even if no newline, or "%%" is found. Make sure not to do this
          # check for the very first line!
          if idx>1 and not new_cell[idx]:
              if md[idx] != md[idx-1]:
                  new_cell[idx] = True
  
          source.append(this_source)
      # This defines the breaking points between cells:
      new_cell_idx = np.hstack([np.where(new_cell)[0], -1])
  
      # Listify the sources:
      cell_source = [source[new_cell_idx[i]:new_cell_idx[i+1]]
                     for i in range(len(new_cell_idx)-1)]
      cell_md = [md[new_cell_idx[i]] for i in range(len(new_cell_idx)-1)]
      cells = []
  
      # Append the notebook with loading matlab magic extension
      notebook_head = "import pymatbridge as pymat\n" + "ip = get_ipython()\n" \
                      + "pymat.load_ipython_extension(ip)"
      cells.append(nbformat.new_code_cell(notebook_head))#, language='python'))
  
      for cell_idx, cell_s in enumerate(cell_source):
          if cell_md[cell_idx]:
              cells.append(nbformat.new_markdown_cell(cell_s))
          else:
              cell_s.insert(0, '%%matlab\n')
              cells.append(nbformat.new_code_cell(cell_s))#, language='matlab'))
  
      #ws = nbformat.new_worksheet(cells=cells)
      notebook = nbformat.new_notebook(cells=cells)
      return notebook