Skip to content

Instantly share code, notes, and snippets.

@ryneches
Created August 29, 2022 08:33
Show Gist options
  • Save ryneches/6fca27fecc9d64a8e731214c069095f1 to your computer and use it in GitHub Desktop.
Save ryneches/6fca27fecc9d64a8e731214c069095f1 to your computer and use it in GitHub Desktop.
Handlebars template for converting Jupyter Notebook JSON blobs into Markdown
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"id": "2255c947",
"metadata": {},
"source": [
"### This is a test notebook\n",
"\n",
"This notebook is for testing the Handlebars template for displaying\n",
"[Jupyter notebooks](https://jupyter.org) in [Obsidian](https://obsidian.md)."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "3ea5b520",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"This is some output!\n"
]
}
],
"source": [
"# this is some code!\n",
"print( 'This is some output!' )"
]
}
],
"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.5"
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 5
}

{{#each cells}} {{#if ( eq this.cell_type "markdown" ) }} {{#each this.source}}{{this}}{{/each}} {{/if}} {{#if ( eq this.cell_type "code" ) }} In [ {{this.execution_count}} ] : ''' {{#each this.source}}{{this}}{{/each}} ''' Out : ''' {{#each this.outputs}} {{#if ( eq this.output_type "stream" )}} {{#each this.text}}{{this}}{{/each}} {{/if}} {{/each}} ''' {{/if}} {{/each}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment