code: def test_jupytext_markdown_similar_to_nbconvert(ipynb_py_R_jl_file):
      """Test that the nbconvert export for a notebook matches Jupytext's one"""
      if "magic" in ipynb_py_R_jl_file or "html" in ipynb_py_R_jl_file:
          pytest.skip()
  
      nb = jupytext.read(ipynb_py_R_jl_file)
  
      # Remove cell outputs and metadata
      for cell in nb.cells:
          if "outputs" in cell:
              cell.outputs = []
          if "metadata" in cell:
              cell.metadata = {}
  
      md_jupytext = jupytext.writes(nb, fmt="md")
  
      import nbconvert
  
      md_nbconvert, _ = nbconvert.export(nbconvert.MarkdownExporter, nb)
  
      # our expectations
  
      # nbconvert file has no YAML header
      md_jupytext_lines = md_jupytext.splitlines()
      _, _, raw_cell, pos = header_to_metadata_and_cell(
          md_jupytext_lines, "", ""
      )
      md_jupytext = "\n".join(md_jupytext_lines[pos:]) + "\n"
      if raw_cell is not None:
          md_jupytext = raw_cell.source + "\n\n" + md_jupytext
  
      # region comments are not in nbconvert
      md_jupytext = md_jupytext.replace(
          "<!-- #region -->\n", ""
      ).replace("<!-- #endregion -->\n", "")
  
      # Jupytext uses HTML comments to keep track of raw cells
      md_jupytext = (
          md_jupytext.replace("\n<!-- #raw -->\n", "")
          .replace("<!-- #raw -->\n", "")
          .replace("\n<!-- #endraw -->\n", "")
      )
  
      # nbconvert file may start with an empty line
      md_jupytext = md_jupytext.lstrip("\n")
      md_nbconvert = md_nbconvert.lstrip("\n")
  
      # Jupytext may not always have two blank lines between cells like Jupyter nbconvert
      md_jupytext = md_jupytext.replace("\n\n\n", "\n\n")
      md_nbconvert = md_nbconvert.replace("\n\n\n", "\n\n")
  
      jupytext.compare.compare(md_nbconvert, md_jupytext)
  
imports: import pytest
  import jupytext
  from jupytext.header import header_to_metadata_and_cell
label_desc: Use image node_id 2 for calling a global function with example usage: test_jupytext_markdown_similar_to_nbconvert(ipynb_py_R_jl_file) without return types