GetRD / academic-file-converter

📚 Import Bibtex publications and Jupyter Notebook blog posts into your Markdown website or book. 将Bibtex转换为Markdown网站

Home Page:https://docs.hugoblox.com/reference/content-types/#automatically-import-publications-from-bibtex

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automatically convert Jupyter notebooks to Markdown

gcushen opened this issue · comments

commented

Use the Python nbconvert module to clean up Jupyter notebooks and import them as blog posts.

Algo idea:

  1. Recursively locate all Jupyter notebooks in a site's notebooks/ folder
  2. Parse each notebook into a Markdown page bundle within content/post/ folder using nbconvert's Python function
    • defaults to the h1 heading (falling back to filename) as the Hugo page title, and the conversion date for date
    • If the first cell is Jupyter 'raw' type and begins with --- (YAML) use it as the page's front matter and hide that cell from the output
    • Fetch front matter options from notebook metadata field

Tests:

  • Add a unit test on a Jupyter notebook and check the Markdown output

I've worked with nbconvert in the past. However, are we to assume that exports should be done as-is, or would there be an intent to integrate some use-defined way to allow for things like the RemoveTagsPreprocessor to be used?

commented

@ionlights thanks - I've updated the rough WIP algo above. Initially, lets keep it simple and only remove the first cell if it contains raw YAML front matter.

commented

Implemented in 637ab31