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 a binder... and entirely too much else... #10

Merged
merged 31 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f585e69
start binder
bollwyvl Nov 1, 2020
343e72b
add serverextension for wasm serving
bollwyvl Nov 1, 2020
872a3dd
ignoring more files, specify python version
bollwyvl Nov 1, 2020
ad7442e
rework with manager, expose plugin machinery, lazy load more
bollwyvl Nov 1, 2020
1ddc7f2
contributing docs
bollwyvl Nov 1, 2020
3c137d4
rework API, add bootstrap
bollwyvl Nov 1, 2020
9c006f1
add link replacer, options to API, typings in folder
bollwyvl Nov 1, 2020
0cf57cb
more docs
bollwyvl Nov 1, 2020
6091df8
add anchor links, clean up bootstrap build
bollwyvl Nov 1, 2020
2bbe34a
try more building
bollwyvl Nov 1, 2020
e2dd064
add legacy header link class
bollwyvl Nov 2, 2020
8700c0c
handle plugins with multiple options
bollwyvl Nov 2, 2020
7ca1f71
task lists
bollwyvl Nov 2, 2020
5eee047
per-plugin options
bollwyvl Nov 2, 2020
6db1e21
refactor builtins
bollwyvl Nov 2, 2020
b1b11ba
slim down CONTRIBUTING
bollwyvl Nov 2, 2020
cc9414d
add settings boilerplate
bollwyvl Nov 2, 2020
bb3a9ab
basic style, table
bollwyvl Nov 2, 2020
9d7b9e4
add plugin disabling
bollwyvl Nov 3, 2020
cd98b74
use article/section instead of table
bollwyvl Nov 3, 2020
32fa80e
some more style tweaks
bollwyvl Nov 3, 2020
56c31b5
fix nav
bollwyvl Nov 3, 2020
cce39bd
fix rel
bollwyvl Nov 3, 2020
96bff91
provide advanced settings escape hatch
bollwyvl Nov 3, 2020
dfb18aa
add default value to markdownit options
bollwyvl Nov 3, 2020
ed3e4c6
remove redundant link replacer, add main menu entries, some docs
bollwyvl Nov 4, 2020
909c4d6
lab-compatible anchor slugs, docs, add toc to binder, linting, clean …
bollwyvl Nov 4, 2020
d05f347
add binder links
bollwyvl Nov 4, 2020
d999d7d
more badges
bollwyvl Nov 4, 2020
d57f382
unwrap docs links
bollwyvl Nov 5, 2020
2333689
remove async from enabled check because cache
bollwyvl Nov 6, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .binder/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: jupyterlab-markup

channels:
- conda-forge
- nodefaults

dependencies:
- jupyterlab >=2,<3
- nodejs >=14,<15
- python >=3.7,<3.8
11 changes: 11 additions & 0 deletions .binder/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -eux

python -m pip install -e . --no-deps --ignore-installed
jupyter serverextension enable jupyterlab_markup --sys-prefix
jlpm bootstrap
jupyter labextension install $(npm pack) --no-build --debug
jupyter lab build --debug --dev-build=False --minimize=False

jupyter labextension list
jupyter serverextension list
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
__pycache__
.ipynb_checkpoints
*.bundle.*
lib/
node_modules/
*.egg-info/
.ipynb_checkpoints
build/
demo/
dist/
lib/
node_modules/
untitled*
Untitled*
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__pycache__/
*.egg-info/
build/
lib/
node_modules/
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
34 changes: 34 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## Development

For a development install (requires npm version 4 or later), do the following in the repository directory:

```bash
python -m pip install -e .
jupyter serverextension enable jupyterlab_markup
jlpm bootstrap
jupyter labextension install .
```

To rebuild the package and the JupyterLab app:

```bash
jlpm build
jupyter lab build
```

For live development

```bash
jlpm watch # will continue running
jupyter lab watch # in another terminal, will continue running
```

## Extending

Additional [`markdown-it` plugins][plugins]
can be added as small labextensions. After getting started with the [official cookiecutter][],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be much easier once we can pip install labextensions!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for users, yes. contributors will need even more webpack stuff, and will have to track to a specific version of a jupyterlab-specific package. however, the dev docs for this repo will still be pretty simple, with the addition of jupyter labextension build ..

your `plugin.ts` might look something like the the [builtins](./src/builtins/),
which use the `simpleMarkdownItPlugin` boilerplate [wrapper](./src/utils.ts).

[official cookiecutter]: https://github.com/jupyterlab/extension-cookiecutter-ts
[plugins]: https://www.npmjs.com/search?q=keywords:markdown-it-plugin
27 changes: 27 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2020 Angus Hollands
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include LICENSE.txt
60 changes: 31 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,66 @@

Adds additional rendering support to markdown in JupyterLab by using [markdown-it](https://github.com/markdown-it/markdown-it), and the following plugins:

* [markdown-it-diagrams](https://github.com/agoose77/markdown-it-diagrams)
* [markdown-it-footnote](https://github.com/markdown-it/markdown-it-footnote)
* [markdown-it-deflist](https://github.com/markdown-it/markdown-it-deflist)


![Full example rendering vs markup.](https://i.imgur.com/OL9oGcq.png)
![svgbob rendering](https://i.imgur.com/RbDioU8.gif)
![svgbob rendering](https://i.imgur.com/IQSasVZ.gif)

- [markdown-it-anchor](https://github.com/valeriangalliat/markdown-it-anchor)
- [markdown-it-deflist](https://github.com/markdown-it/markdown-it-deflist)
- [markdown-it-diagrams](https://github.com/agoose77/markdown-it-diagrams)
- [markdown-it-footnote](https://github.com/markdown-it/markdown-it-footnote)
- [markdown-it-replace-link](https://github.com/martinheidegger/markdown-it-replace-link)
- [markdown-it-task-lists](https://github.com/revin/markdown-it-task-lists)
![Full example rendering vs markup.](https://i.imgur.com/OL9oGcq.png)
![svgbob rendering](https://i.imgur.com/RbDioU8.gif)
![svgbob rendering](https://i.imgur.com/IQSasVZ.gif)

## Prerequisites

* JupyterLab
- JupyterLab 2

## Installation

Ensure mimetype exists for wasm:
```bash
echo "application/wasm wasm" | sudo tee -a /etc/mime.types
```

Install extension:

```bash
pip install jupyterlab_markup
jupyter labextension install @agoose77/jupyterlab-markup
```

You will need to reinstall the extension if you do these steps out of order.

## Development

For a development install (requires npm version 4 or later), do the following in the repository directory:
Ensure the extensions are enabled:

```bash
npm install
npm run build
jupyter labextension link .
jupyter labextension list # should contain @goose/jupyterlab-markup
jupyter serverextension list # should contain jupyterlab_markup
```

To rebuild the package and the JupyterLab app:
If the serverextension is missing, try...

```bash
npm run build
jupyter lab build
jupyter serverextension enable jupyterlab_markup
```

``` mermaid
## Contributing

Please see the [contributor guide](./CONTRIBUTING.md)!

## Examples

### mermaid

```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```
``` bob

### svgbob

```bob
.---.
/-o-/--
.-/ / /->
( * \/
'-. \
\ /
'
```
```
7 changes: 7 additions & 0 deletions etc/jupyterlab-markup-serverextension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"NotebookApp": {
"nbserver_extensions": {
"jupyterlab_markup": true
}
}
}
136 changes: 136 additions & 0 deletions index.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Table of Contents\n",
"\n",
"| plugin... | provides... |\n",
"|----------------------------|-----------------------------------------|\n",
"| `markdown-it-anchor` | header anchors |\n",
"| `markdown-it-diagrams` | [diagrams](#diagrams) |\n",
"| `markdown-it-deflist` | [definition lists](#definition-lists) |\n",
"| `markdown-it-footnote` | [footnotes](#footnotes) |\n",
"| `markdown-it-replace-link` | link replacement |\n",
"| `markdown-it-task-lists` | [task lists](#task-lists) |"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Definition Lists\n",
"\n",
"\n",
"Term 1\n",
" ~ Definition 1\n",
"\n",
"Term 2\n",
" ~ Definition 2a\n",
" ~ Definition 2b"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Diagrams"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Mermaid"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```mermaid \n",
"graph TD;\n",
" A-->B;\n",
" A-->C;\n",
" B-->D;\n",
" C-->D;\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### svgbob"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```bob \n",
" .---.\n",
" /-o-/--\n",
" .-/ / /->\n",
"( * \\/\n",
" '-. \\\n",
" \\ /\n",
" '\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Footnotes"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here is a footnote reference,[^1] and another.[^longnote]\n",
"\n",
"[^1]: Here is the footnote.\n",
"\n",
"[^longnote]: Here's one with multiple blocks.\n",
"\n",
" Subsequent paragraphs are indented to show that they\n",
"belong to the previous footnote."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Task Lists\n",
"\n",
"- [x] done\n",
"- [ ] not done"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.8"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading