Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mnkiefer/html2notebook

Convert static HTML files to notebooks
https://github.com/mnkiefer/html2notebook

cap-notebook html jupyter-notebook note notebook

Last synced: 3 days ago
JSON representation

Convert static HTML files to notebooks

Awesome Lists containing this project

README

        

# html2notebook

**html2notebook** is a conversion tool that let's you translate _HTML_ to [notebooks](#supported-notebook-formats).

| Notebook type | File extension | Supported |
| :------------------------------------------------------------------------: | :------------: | :-------: |
| [CAP Notebook](https://cap.cloud.sap/docs/tools/#cap-vscode-notebook) | .capnb | ✓ |
| [Jupyter Notebook](https://docs.jupyter.org/en/latest/#what-is-a-notebook) | .ipynb | ✓ |

## Installation

```sh
npm install html2notebook
```

## Usage

Let's consider we have the following file _test.html_ as input:

```html


TEXT N2



CODE N5
TEXT N11



TEXT N6




TEXT N8

CODE N9

```

To generate a type _Jupyter_ notebook:

```js
const { html2notebook } = require("html2notebook");

const html = fs.readFileSync("test.html", "utf8");
const nb = html2notebook(html);

console.log(nb);
```

This produces the following output:

```swift
{
"metadata": {
"language_info": {
"name": "python"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2,
"cells": [
{
"attachments": {},
"metadata": {},
"cell_type": "markdown",
"source": [
"",
"

",
"
",
" TEXT N2",
"
",
"
",
"
",
"

"
]
},
{
"metadata": {},
"execution_count": null,
"outputs": [],
"cell_type": "code",
"source": [
"CODE N5",
" "
]
},
{
"attachments": {},
"metadata": {},
"cell_type": "markdown",
"source": [
"

",
"
TEXT N6
",
"
",
"
",
"
",
"
TEXT N8
",
"

"
]
},
{
"metadata": {},
"execution_count": null,
"outputs": [],
"cell_type": "code",
"source": [
"CODE N9"
]
},
{
"attachments": {},
"metadata": {},
"cell_type": "markdown",
"source": [
"

",
"
",
"
",
""
]
}
]
}
```