def convert(self,
                contents_or_path,
                from_=None,
                to=None,
                reader=None,
                writer=None,
                from_kwargs=None,
                to_kwargs=None,
                ):
        """Convert contents between supported formats.

        Parameters
        ----------

        contents : str
            The contents to convert from.
        from_ : str or None
            The name of the source format. If None, this is the
            ipymd_cells format.
        to : str or None
            The name of the target format. If None, this is the
            ipymd_cells format.
        reader : a Reader instance or None
        writer : a Writer instance or None
        from_kwargs : dict
            Optional keyword arguments to pass to the reader instance.
        to_kwargs : dict
            Optional keyword arguments to pass to the writer instance.

        """

        # Load the file if 'contents_or_path' is a path.
        if _is_path(contents_or_path):
            contents = self.load(contents_or_path, from_)
        else:
            contents = contents_or_path

        if from_kwargs is None:
            from_kwargs = {}
        if to_kwargs is None:
            to_kwargs = {}

        if reader is None:
            reader = (self.create_reader(from_, **from_kwargs)
                      if from_ is not None else None)

        if writer is None:
            writer = (self.create_writer(to, **to_kwargs)
                      if to is not None else None)

        if reader is not None:
            # Convert from the source format to ipymd cells.
            cells = [cell for cell in reader.read(contents)]
        else:
            # If no reader is specified, 'contents' is assumed to already be
            # a list of ipymd cells.
            cells = contents

        notebook_metadata = [cell for cell in cells
                             if cell["cell_type"] == "notebook_metadata"]

        if writer is not None:
            if notebook_metadata:
                [cells.remove(cell) for cell in notebook_metadata]
                notebook_metadata = self.clean_meta(
                    notebook_metadata[0]["metadata"]
                )
                if hasattr(writer, "write_notebook_metadata"):
                    writer.write_notebook_metadata(notebook_metadata)
                else:
                    print("{} does not support notebook metadata, "
                          "dropping metadata: {}".format(
                              writer,
                              notebook_metadata))

            # Convert from ipymd cells to the target format.
            for cell in cells:
                meta = self.clean_cell_meta(cell.get("metadata", {}))
                if not meta:
                    cell.pop("metadata", None)
                writer.write(cell)

            return writer.contents
        else:
            # If no writer is specified, the output is supposed to be
            # a list of ipymd cells.
            return cells
Convert contents between supported formats.

        Parameters
        ----------

        contents : str
            The contents to convert from.
        from_ : str or None
            The name of the source format. If None, this is the
            ipymd_cells format.
        to : str or None
            The name of the target format. If None, this is the
            ipymd_cells format.
        reader : a Reader instance or None
        writer : a Writer instance or None
        from_kwargs : dict
            Optional keyword arguments to pass to the reader instance.
        to_kwargs : dict
            Optional keyword arguments to pass to the writer instance.