docs: def convert(notebook_path, exporter, output_folder=None, images_folder=None):
      """
      Converts notebook into an HTML file, outputting notebooks into
      output_folder if set and images into images_folder if set.
  
      Returns the path to the resulting HTML file.
      """
      if output_folder:
          os.makedirs(output_folder, exist_ok=True)
      if images_folder:
          os.makedirs(images_folder, exist_ok=True)
  
      # Computes notebooks/ch1 and <name>.ipynb from notebooks/ch1/<name>.ipynb
      path, filename = os.path.split(notebook_path)
      # Computes <name> from <name>.ipynb
      basename, _ = os.path.splitext(filename)
      # Computes <name>.html from notebooks/<name>.ipynb
      outfile_name = basename + '.html'
  
      # If output_folder is not set, we default to the original folder of the
      # notebook.
      out_folder = path if not output_folder else output_folder
      outfile_path = os.path.join(out_folder, outfile_name)
  
      notebook = nbformat.read(notebook_path, as_version=4)
  
      html, resources = exporter.from_notebook_node(
          notebook,
          resources=make_exporter_resources(basename, out_folder, images_folder),
      )
  
      # Write out HTML
      with open(outfile_path, 'w', encoding='utf-8') as outfile:
          outfile.write(html)
  
      # Write out images. If images_folder wasn't specified, resources['outputs']
      # is None so this loop won't run
      for image_path, image_data in resources.get('outputs', {}).items():
          with open(image_path, 'wb') as outimage:
              outimage.write(image_data)
  
      return outfile_path