Skip to main content

A markdown kernel for Jupyter

Project description

Anaconda-Server Badge PyPI version

A markdown kernel for Jupyter

Installation

If you are using a conda environment, you can install markdown-kernel with command

conda install -c conda-forge markdown-kernel

Otherwise, with a working Jupyter installation, you can install markdown-kernel with commands

pip install markdown-kernel
python -m markdown_kernel.install

You can verify if a markdown kernel is properly installed with command

jupyter kernelspec list

Use a markdown kernel by itself

markdown-kernel is a simple Jupyter kernel that displays cell content as markdown. To use this kernel, you can start a Jupyter server with command jupyter notebook or jupyter lab, create a notebook with this kernel, enter and render markdown texts.

image

But wait, this is stupid because you can do the same thing in Jupyter, only easier. What is the point of a markdown kernel by itself?

Use a Markdown kernel in SoS Notebook

If you are familiar with R Markdown, you might know and like its inline code that allows results to be inserted directly into the text of a .Rmd file by enclosing the code with `r `. This is really convenient for writing Rmarkdown report but cannot be done in Jupyter because Jupyter's markdown cells are rendered at the frontend and do not interact with Jupyter kernels (See ipython/ipython#2592, jupyter/help#41,and jupyter/notebook#3463 for related discussions).

SoS Notebook is a Jupyter kernel that supports the use of multiple kernels in one Jupyter notebook. Although a markdown kernel by itself cannot interpolate and evaluate expressions either, you can the %expand magic of SoS to enable inline expressions in Jupyter, for Python, R, and potentially many other languages. Here is how it works:

Expand expressions with SoS (Python) variables

The SoS kernel is a super kernel that starts and communicates with all other Jupyter kernels. Its syntax is a super set of Python 3.6+ so you can execute any Python code in SoS kernels. The %expand magic treats the content of a markdown cell as a Python f-string and expands expressions enclosed in { }, or other delimiters as option of magic %expand.

image

NOTE: Starting from jupyterlab-sos version 0.6.3, the input of codecell with Markdown kernel are folded automatically after cell execution.

Expand expressions in subkernels such as R

The --in option of magic %expand allows you to expand the cell content in specified subkernel, if its language module supports the expand protocol. This allows the content in markdown cells to be expanded in other languages such as R. Most notably, you can use

%expand `r ` --in R

to expand inline expressions in R Markdown texts.

image

This technique is used by sos-rmarkdown, a RMarkdown to SoS Notebook converter to convert markdown text with inline expressions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

markdown-kernel-0.2.2.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

markdown_kernel-0.2.2-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file markdown-kernel-0.2.2.tar.gz.

File metadata

  • Download URL: markdown-kernel-0.2.2.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3

File hashes

Hashes for markdown-kernel-0.2.2.tar.gz
Algorithm Hash digest
SHA256 be56278d195a6188f8878abe2a2fed056e5ff700e1b22cc88e07f87d5493e9c0
MD5 7cd96780a889958f234eb1ad9423d60f
BLAKE2b-256 36dba7de227fa16241feca8daf354d8a6b178f9f59d2c041b9291eb75c411a8d

See more details on using hashes here.

File details

Details for the file markdown_kernel-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: markdown_kernel-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3

File hashes

Hashes for markdown_kernel-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 82da85042273534073c9ecf59c0ebd6105f9dbc8c24e7e688bb7fc72ac00336b
MD5 de2bd17eb77a918a34ccdb90e69b989f
BLAKE2b-256 4ad89c6ca8491151701dd38c46bdaa36c369dec48e23ba5cdff88bbcf4aea761

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page