Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add license to Jupyter notebooks as Markdown cell #1053

Open
SJaffa opened this issue Jul 24, 2024 · 2 comments
Open

Add license to Jupyter notebooks as Markdown cell #1053

SJaffa opened this issue Jul 24, 2024 · 2 comments
Labels
comment-styles Request for a new comment style, or fixing a bug with these

Comments

@SJaffa
Copy link

SJaffa commented Jul 24, 2024

Jupyter notebooks are currently treated as "Uncommentable". Could the license information be added as a new Markdown cell at the top of the notebook rather than a comment or a separate .license file?

@SJaffa SJaffa changed the title Add license comment to Jupyter notebooks Add license to Jupyter notebooks as Markdown cell Jul 24, 2024
@carmenbianca
Copy link
Member

Hi @SJaffa. Can you give an example?

@carmenbianca carmenbianca added the comment-styles Request for a new comment style, or fixing a bug with these label Jul 24, 2024
@SJaffa
Copy link
Author

SJaffa commented Jul 29, 2024

A Jupyter notebook's underlying structure is a JSON file containing a list of cells. Example:

{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "9b216162",
   "metadata": {},
   "source": [
    "First markdown cell text"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "505c6c8f",
   "metadata": {},
   "source": [
    "Second markdown cell text"
   ]
  },
...
 },
 "nbformat": 4,
 "nbformat_minor": 5
}

If you can identify the start of the "cells": [ list you can add a new cell at the top containing the license text in the source:

  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "License text here"
   ]
  },

All the cells have an id but I experimented with adding a new cell to the JSON without an id and it seems to work fine and just adds that field when it renders it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comment-styles Request for a new comment style, or fixing a bug with these
Projects
None yet
Development

No branches or pull requests

2 participants