Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
126 changes: 126 additions & 0 deletions examples/display-markdown.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "1445c778-f92f-46c4-a7f9-b9aece94450f",
"metadata": {
"user_expressions": []
},
"source": [
"---\n",
"title: Markdown Rendering in Jupyter using MyST\n",
"subtitle: Using inline widgets in JupyterLab markdown cells\n",
"author:\n",
" - name: Rowan Cockett\n",
" affiliations: Executable Books; Curvenote\n",
" orcid: 0000-0002-7859-8394\n",
" email: rowan@curvenote.com\n",
" - name: Angus Hollands\n",
" affiliations: Executable Books\n",
" - name: Steve Purves\n",
" affiliations: Executable Books; Curvenote\n",
"date: 2023/02/20\n",
"---\n",
"\n",
"The [JupyterLab MyST extension](https://github.com/executablebooks/jupyterlab-myst) allows you to invoke the MyST renderer from code cell outputs."
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "53c89be3-63ef-4a5c-b7f3-28ed138fa92e",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from IPython.display import Markdown"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "32fad109-f60a-4162-b784-4e3d9ed45921",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/markdown": [
"\n",
"\n",
"\n",
"The [JupyterLab MyST extension](https://github.com/executablebooks/jupyterlab-myst) allows you to have MyST renderer in your markdown cells that includes interactivity and inline-evaluation.\n",
"\n",
":::{warning} Syntax is Subject to Change\n",
":class: dropdown\n",
"The current syntax is based on a myst role, which may change in the future -- for example to be closer to an inline expression `${}`. This will go through a MyST enhancement proposal, and the `{eval}` role will likely still be supported.\n",
":::\n",
"\n",
"\n",
"```python\n",
"import numpy as np\n",
"array = np.arange(4)\n",
"```\n",
"\n"
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Markdown('''\n",
"\n",
"\n",
"The [JupyterLab MyST extension](https://github.com/executablebooks/jupyterlab-myst) allows you to have MyST renderer in your markdown cells that includes interactivity and inline-evaluation.\n",
"\n",
":::{warning} Syntax is Subject to Change\n",
":class: dropdown\n",
"The current syntax is based on a myst role, which may change in the future -- for example to be closer to an inline expression `${}`. This will go through a MyST enhancement proposal, and the `{eval}` role will likely still be supported.\n",
":::\n",
"\n",
"\n",
"```python\n",
"import numpy as np\n",
"array = np.arange(4)\n",
"```\n",
"\n",
"''')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.10.6"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}
146 changes: 138 additions & 8 deletions examples/inline-interactivity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 1,
"id": "90dffa46-b084-4b24-a650-e5f5a9aa526e",
"metadata": {
"tags": []
Expand Down Expand Up @@ -123,7 +123,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 2,
"id": "5ffba1f7-e455-4dce-a645-38988d97b01b",
"metadata": {
"tags": []
Expand Down Expand Up @@ -170,7 +170,7 @@
"result": {
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "164397fa815540bda67c6789e23fc2f2",
"model_id": "99c2b3b4f0634fb19a6586a1b7c048ad",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -185,7 +185,7 @@
"result": {
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "55495b9c0d0a4752b156300c63c1727f",
"model_id": "1e8ab668a82f4bca84d0731092af405f",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -200,7 +200,7 @@
"result": {
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "99043a572d5b4229ad08203899d80425",
"model_id": "38bb524a0a544221a6d57312a1b24323",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -215,7 +215,7 @@
"result": {
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "47a2a63cb5304db28dd220ff347fb093",
"model_id": "b026379e864a457585df0502be54ba98",
"version_major": 2,
"version_minor": 0
},
Expand Down Expand Up @@ -260,7 +260,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 3,
"id": "17290f9d-034c-41d0-828b-5af14e14edfa",
"metadata": {
"tags": []
Expand Down Expand Up @@ -582,7 +582,137 @@
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {},
"state": {
"0475c9891b1041ac958732b3f3dfde80": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"1e8ab668a82f4bca84d0731092af405f": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "LabelModel",
"state": {
"layout": "IPY_MODEL_2e78dacf92a94dd6aa3919a29722948b",
"style": "IPY_MODEL_480aadd6662c4c2bbcca8ef67255e64a",
"value": "500"
}
},
"274ed93dcd0f4897a95f314dc1f3b1fb": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"2766f4faadcd443f8c195bf614a30035": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "DescriptionStyleModel",
"state": {
"description_width": ""
}
},
"2e78dacf92a94dd6aa3919a29722948b": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"38bb524a0a544221a6d57312a1b24323": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "LabelModel",
"state": {
"layout": "IPY_MODEL_274ed93dcd0f4897a95f314dc1f3b1fb",
"style": "IPY_MODEL_64cee23ec9524879aa172d0271642964",
"value": "23.8"
}
},
"480aadd6662c4c2bbcca8ef67255e64a": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "LabelStyleModel",
"state": {
"description_width": "",
"font_family": null,
"font_size": null,
"font_style": null,
"font_variant": null,
"font_weight": null,
"text_color": null,
"text_decoration": null
}
},
"62a7cd9328f142c98184357d8951af13": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "SliderStyleModel",
"state": {
"description_width": ""
}
},
"64cee23ec9524879aa172d0271642964": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "LabelStyleModel",
"state": {
"description_width": "",
"font_family": null,
"font_size": null,
"font_style": null,
"font_variant": null,
"font_weight": null,
"text_color": null,
"text_decoration": null
}
},
"72a3e705505044a49019394d40092e25": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"888a2a0691f44d008052ded919537342": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "LinkModel",
"state": {
"source": [
"IPY_MODEL_b026379e864a457585df0502be54ba98",
"value"
],
"target": [
"IPY_MODEL_99c2b3b4f0634fb19a6586a1b7c048ad",
"value"
]
}
},
"99c2b3b4f0634fb19a6586a1b7c048ad": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "BoundedIntTextModel",
"state": {
"layout": "IPY_MODEL_72a3e705505044a49019394d40092e25",
"max": 30,
"style": "IPY_MODEL_2766f4faadcd443f8c195bf614a30035",
"value": 10
}
},
"b026379e864a457585df0502be54ba98": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "IntSliderModel",
"state": {
"behavior": "drag-tap",
"description": "Cookies: ",
"layout": "IPY_MODEL_0475c9891b1041ac958732b3f3dfde80",
"max": 30,
"style": "IPY_MODEL_62a7cd9328f142c98184357d8951af13",
"value": 10
}
}
},
"version_major": 2,
"version_minor": 0
}
Expand Down
2 changes: 1 addition & 1 deletion examples/myst_tests.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.10.6"
},
"vscode": {
"interpreter": {
Expand Down
Loading