reuse-tool icon indicating copy to clipboard operation
reuse-tool copied to clipboard

Add license to Jupyter notebooks as Markdown cell

Open SJaffa opened this issue 1 year ago • 2 comments

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 avatar Jul 24 '24 14:07 SJaffa

Hi @SJaffa. Can you give an example?

carmenbianca avatar Jul 24 '24 15:07 carmenbianca

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.

SJaffa avatar Jul 29 '24 13:07 SJaffa

Hi! This repository is being migrated away from GitHub towards Codeberg. More context can be found in #865. This issue can henceforth be found at https://codeberg.org/fsfe/reuse-tool/issues/1053. Any comments subsequent to this comment will not be migrated.

carmenbianca avatar Nov 24 '25 14:11 carmenbianca