Jupyter2Hashnode is a useful tool for converting Jupyter Notebooks into Hashnode stories by simplifying the process of compressing images, uploading images, and publishing the story article.
See the full documentation here
How to install
$ pip install jupyter2hashnode
Using as a command line tool
If jwt, token, publication_id arguments not passed then will use environment variables HASHNODE_JWT, HASHNODE_TOKEN, HASHNODE_PUBLICATION_ID.
Notes:
To obtain JWT: Open https://hashnode.com, account must be logged in, open DevTools of chrome browser (F12), go to Application tab, go to Cookies, find and copy value of "jwt" cookie (245 characters)
To obtain Hashnode API token: Open https://hashnode.com/settings/developer, click on "Generate New Token" button or use the existing one
To obtain Publication ID: Go to https://hashnode.com/settings/blogs, click "Dashboard" of the blog you want to upload to, copy the ID, e.g. https://hashnode.com//dashboard
Usage:
$ jupyter2hashnode [OPTIONS] NOTEBOOK_PATH [OUTPUT_PATH]
Arguments:
NOTEBOOK_PATH: notebook file name or complete path [required][OUTPUT_PATH]: output folder name or complete output path where the files will be written to, if none creates output folder with the same name as the notebook file name
Options:
-j, --jwt TEXT: JWT token for authentication at https://hashnode.com/api/upload-image.-t, --token TEXT: Token for authentication at https://api.hashnode.com mutation createPublicationStory endpoint-p, --publication TEXT: ID of the Hashnode publication e.g. https://hashnode.com//dashboard--title TEXT: Article title [required]--hide-from-feed / --no-hide-from-feed: Hide this article from Hashnode and display it only on your blog [default: True]--delete-files / --no-delete-files: Delete all files after creating the publication story [default: True]--upload / --no-upload: Upload the publication story to the Hashnode server [default: True]-v, --version: Show the application's version and exit.--install-completion: Install completion for the current shell.--show-completion: Show completion for the current shell, to copy it or customize the installation.--help: Show this message and exit.
Using as a library
class Jupyter2Hashnode
Notes:
- To obtain JWT
- Open https://hashnode.com, account must be logged in
- Open DevTools of chrome browser (F12)
- Go to Application tab
- Go to Cookies
- Find and copy value of "jwt" cookie (245 characters)
- To obtain Hashnode API token
- Open https://hashnode.com/settings/developer
- Click on "Generate New Token" button or use the existing one
- To obtain Publication ID
- Go to https://hashnode.com/settings/blogs
- Click on "Dashboard" button of the blog you want to upload to
- Copy ID from the URL, e.g. https://hashnode.com//dashboard
Attributes:
HASHNODE_JWT (str): JWT token for authentication at Hashnode image uploader, https://hashnode.com/api/upload-image.
HASHNODE_TOKEN (str): Token for authentication with the Hashnode server, to use https://api.hashnode.com
mutation createPublicationStory endpoint
HASHNODE_PUBLICATION_ID (str): ID of the Hashnode publication e.g. https://hashnode.com/<id>/dashboard
Methods:
create_publication_story(title:str, notebook_path: str, output_path:Optional[str]=None,
delete_files:bool=True, upload:bool=True):
This function is used to create a publication story on the Hashnode blog platform by
converting a Jupyter Notebook to a markdown file, compressing images, uploading images
to the Hashnode server, and replacing image URLs in the markdown file.
Parameters:
title (str): Title of the publication story.
notebook_path (str): Path to the Jupyter Notebook file.
hide_from_feed (bool): Hide this article from Hashnode and display it only on your blog, Default is True.
output_path (str, optional): Path to the output directory. Default is None.
delete_files (bool, optional): Boolean value indicating whether to delete all files after
creating the publication story. Default is True.
upload (bool, optional): Boolean value indicating whether to upload the publication story
to the Hashnode server. Default is True.
Returns:
None
Usage:
from jupyter2hashnode import Jupyter2Hashnode
j2h = Jupyter2Hashnode(jwt, token, publication_id)
j2h.create_publication_story(title, notebook_path, hide_from_feed, output_path, delete_files, upload)
Metadata
Release files for jupyter2hashnode 0.1.31
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jupyter2hashnode-0.1.31.tar.gz | 81.5 kB | Without provenance | Details for jupyter2hashnode-0.1.31.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jupyter2hashnode-0.1.31-py3-none-any.whl | Python 3 | none | any | Details for jupyter2hashnode-0.1.31-py3-none-any.whl |
Total release size: 164.1 kB
Release files / jupyter2hashnode-0.1.31.tar.gz
| Download URL | jupyter2hashnode-0.1.31.tar.gz |
|---|---|
| Size | 81.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d8bd1c06d653cad428eaa55bfc2edee726f780b379f7ec2f604e811ee291909
|
|
BLAKE2b-256 checksum How to use checksums |
853a76645631eb6759132637e151fdd159ec039e442d88e2d4a56842d9f6bc38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.9.2 Windows/10
|
Release files / jupyter2hashnode-0.1.31-py3-none-any.whl
| Download URL | jupyter2hashnode-0.1.31-py3-none-any.whl |
|---|---|
| Size | 82.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80aa48335bd8aad27f399e0d3ceb7c2d1094db8b33fece84c506ba9a5f03a5aa
|
|
BLAKE2b-256 checksum How to use checksums |
4557b35c927e4aff5c868b58a61dc3c5927629835643017d3f942eb8685a6d6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.9.2 Windows/10
|
Security for jupyter2hashnode 0.1.31
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.