code: def test_wrap_markdown_cell(tmpdir):
      """Use a pre-commit hook to sync a notebook to a script paired in a tree, and reformat
      the markdown cells using pandoc"""
  
      tmpdir.join("jupytext.toml").write(
          """# By default, the notebooks in this repository are in the notebooks subfolder
      # and they are paired to scripts in the script subfolder.
      formats = "notebooks///ipynb,scripts///py:percent"
      """
      )
  
      git = git_in_tmpdir(tmpdir)
      hook = str(tmpdir.join(".git/hooks/pre-commit"))
      with open(hook, "w") as fp:
          fp.write(
              "#!/bin/sh\n"
              "jupytext --pre-commit --sync --pipe-fmt ipynb --pipe \\\n"
              "    'pandoc --from ipynb --to ipynb --atx-headers'\n"
          )
  
      st = os.stat(hook)
      os.chmod(hook, st.st_mode | stat.S_IEXEC)
  
      nb_file = (
          tmpdir.mkdir("notebooks")
          .mkdir("subfolder")
          .join("wrap_markdown.ipynb")
      )
      long_text = "This is a " + ("very " * 24) + "long sentence."
      nb = new_notebook(cells=[new_markdown_cell(long_text)])
      write(nb, str(nb_file))
  
      nb = read(str(nb_file))
      assert nb.cells[0].source == long_text
  
      git("add", str(nb_file))
      git("commit", "-m", "'notebook with long cells'")
  
      py_text = (
          tmpdir.join("scripts")
          .join("subfolder")
          .join("wrap_markdown.py")
          .read()
      )
      assert "This is a very very" in py_text
      for line in py_text.splitlines():
          assert len(line) <= 79
  
      nb = read(nb_file, as_version=4)
      text = nb.cells[0].source
      assert len(text.splitlines()) >= 2
      assert text != long_text
  
file_path: jupytext/tests/external/pre_commit/test_pre_commit_scripts.py
imports: import os
  import stat
  import unittest.mock
  import pytest
  from nbformat.v4.nbbase import new_code_cell, new_markdown_cell, new_notebook
  from jupytext import read, write
  from jupytext.cli import jupytext, system
  from jupytext.compare import compare_cells, compare_notebooks
label_desc: Use image node_id 10 for calling a global function with example usage: test_wrap_markdown_cell(tmpdir) without return types