{"id":14977191,"url":"https://github.com/peijunz/ipynb2pelican","last_synced_at":"2025-10-28T01:30:38.561Z","repository":{"id":86162249,"uuid":"86185887","full_name":"peijunz/ipynb2pelican","owner":"peijunz","description":"Integrate ipynb with pelican utilizing cell features to represent metadata and do other things in a pythonic way","archived":false,"fork":false,"pushed_at":"2020-08-24T08:39:20.000Z","size":36,"stargazers_count":13,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-08T01:41:25.804Z","etag":null,"topics":["blogging","ipython-notebook","jupyter-notebook","pelican","pelican-plugins"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peijunz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-25T20:18:36.000Z","updated_at":"2022-11-07T00:53:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"5a254506-d94f-47b5-9a57-ed3c2772daa9","html_url":"https://github.com/peijunz/ipynb2pelican","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peijunz%2Fipynb2pelican","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peijunz%2Fipynb2pelican/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peijunz%2Fipynb2pelican/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peijunz%2Fipynb2pelican/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peijunz","download_url":"https://codeload.github.com/peijunz/ipynb2pelican/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238579176,"owners_count":19495510,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blogging","ipython-notebook","jupyter-notebook","pelican","pelican-plugins"],"created_at":"2024-09-24T13:55:16.090Z","updated_at":"2025-10-28T01:30:38.241Z","avatar_url":"https://github.com/peijunz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Jupyter Plugin for Pelican Blog System\n\nThe [ipynb2pelican](https://github.com/peijunz/ipynb2pelican) plugin implements `.ipynb` file format support to pelican.\n\n### Features\n+ Simply convert ipynb to html, no CSS is preserved\n+ Uses preprocessors of nbconvert library\n+ Provides cell-based summary generation\n+ Uses first cell as the most natural and readable metadata\n\nWriting metadata is as simple as writing metadata in markdown file.\n```md\n# This is title\n+ date: 2020-02-22\n+ tags: hello, world\n```\n\u003e Hint: In jupyter notebook, press `Esc+M` will switch selected cell to markdown mode. \n\nIt is recommended (but not required) to organize the metadata items\nwith Markdown bullets (`+`, `-` or `*`).\nThese will be stripped during metadata extraction,\nbut it keeps the metadata cell nicely readable in the notebook, like this:\n\n### This is title\n+ date: 2020-02-22\n+ tags: hello, world\n\n## Overview\nThe plugin is simple:\n\n+ The CSS of jupyter will not be taken into outputs\n+ The summary will be generated by Pelican\n\nBut it is still powerful and extensible:\n\n+ A Solution for metadata\n+ Syntax hightlight by nbconvert\n+ Several configurable preprocessors provided\n    - Metadata Extraction\n    - SubCell Selection\n    - Ignore cells with `#ignore` tag\n    - Empty Cell Removal\n+ You can change [preprocess.py](preprocess.py) and define your own preprocessors\n\n## Preprocessors\nThanks to the preprocessor feature of nbconvert, useful preprocessors are built in this\nproject with on/off options. In your `pelicanconf.py`, you are able to\nset [options](#options) to toggle preprocessors. You are encouraged to [share your own\npreprocessors](https://github.com/peijunz/ipynb2pelican/wiki/Preprocessors)! \n\nDon't worry about preprocessors, switch off all options will have only 3% gain on\nperformance according to the test on my blog. So all of them are enabled by default.\n\n### Metadata Extraction\nAs we stated, all metadata should be stored at the first cell of ipynb. If there is no metadata, then article is treated as draft and use filename as title and slug. After the extraction of metadata, the metdata cell will be removed, as we have extracted all the information. \n\n#### Summary Extration\nBy default, it will generate a summary of size 600. Every extra cell incurs a penalty of 120 chars in case that there are too many small cells. \n\n### Remove Empty Cells\nRemove trivial cells without visible characters using regular expression `\\S`\n\n### Ignore some cells\nYou can include an `#ignore` comment at the beginning\nof a cell of the Jupyter notebook to ignore it, removing it from the post content.\n\nNote it is more strict than `#ignore` tag in pelican-ipynb. The purpose is to prevent kicking normal contents out of post content.\n\n### SubCells Selection\nThe Subcells preprocessor is executed after Metadata preprocessor the metadate cell it self will be removed by Metadata preprocessor), so\nzeroth cell is the first cell after metadata. The start and end should be written in the metadata like:\n```md\n# This is title\n+ date: 2020-02-22\n+ tags: hello, world\n+ subcells: [5, -1]\n```\n\nThe value will be evaluated by `start, end = ast.literal_eval(value)`. And then cells are sliced by `cells[start:end]`.\n\n\u003e Hint: If you want end to be infinity, use None\n\n## Options\n\n|Option Variable|Default|Meaning|\n|------|-------|-------|\n|`IPYNB_REMOVE_EMPTY`|True|Remove Empty Cells|\n|`IPYNB_IGNORE`|True|Remove cells with `#ignore` tag at the beginning|\n|`IPYNB_SUBCELLS`|True|Only preserve Subcells specified by `subcells: [begin, end)` metadata|\n|`SUMMARY_SIZE` | 600 | Size of Summary|\n|`CELL_PENALTY` | 120 | penalty of each cell in summary|\n\n## Installation and Configuration\n### Dependency\n+ Both `python2`, `python3` are supported\n+ `pelican`\n+ `jupyter`\n+ `ipython`\n+ `nbconvert`\n\nIt has been tested on\n\n+ `python 3.6+`\n+ `pelican 4.5`\n+ `jupyter/ipython/nbconvert 4.1`\n\n### Installation\nDownload this repo and rename folder to `ipynb2pelican`. Then put it\ninto your plugins directory. A simpler way is by submodule this plugin:\n\n```sh\ngit submodule add git@github.com:peijunz/ipynb2pelican.git pelican-plugins/ipynb2pelican\n```\n\nIf your plugins are put\ninto `pelican-plugins` directory, the file tree\nshould looks like:\n```\ncontent/\npelicanconf.py\npelican-plugins/\n└── ipynb2pelican\n    ├── __init__.py\n    ├── preprocess.py\n    ├── reader.py\n    └── README.md\n```\n### Configuration\nIn the `pelicanconf.py`:\n```python\nPLUGIN_PATH = ['pelican-plugins']       # Ensure your plugin path is in it\nPLUGINS = ['ipynb2pelican']             # Name of the plugin\nIGNORE_FILES = ['.ipynb_checkpoints']   # Prevent parsing checkpoints files\n```\n\nIf you are not using `pelican-plugins`, you should change it accordingly.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeijunz%2Fipynb2pelican","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeijunz%2Fipynb2pelican","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeijunz%2Fipynb2pelican/lists"}