Convert Jupyter notebook to markdown using jupyter nbconvert.
(notebook_path)
| 40 | |
| 41 | |
| 42 | def convert_notebook_to_markdown(notebook_path): |
| 43 | """Convert Jupyter notebook to markdown using jupyter nbconvert.""" |
| 44 | try: |
| 45 | result = subprocess.run( |
| 46 | ["jupyter", "nbconvert", "--to", "markdown", "--stdout", notebook_path], |
| 47 | capture_output=True, |
| 48 | text=True, |
| 49 | check=True, |
| 50 | ) |
| 51 | return result.stdout |
| 52 | except subprocess.CalledProcessError as e: |
| 53 | sys.exit(f"Error: Failed to convert notebook: {e}\nstderr: {e.stderr}") |
| 54 | except FileNotFoundError: |
| 55 | sys.exit("Error: jupyter nbconvert not found. Please install jupyter: pip install jupyter") |
| 56 | |
| 57 | |
| 58 | def process_pip_installations(markdown_content): |