The REPL Notes platform provides a number of utility commands to make it easy to define how posts are created and rendered. For example, there are commands to set the post title, associate each post to keywords or tags, and for hiding cell inputs or outputs.
The syntax for adding these commands is very simple. There should be one command per line and nothing else written in that line. These commands are designed to be case-insensitive and any number of spaces can be added before or after to achieve the desired formatting. Each command begins with one or more #
symbols. They are designed such that they can be added to either Markdown or code cells. In the code cell, lines beginning with #
will be ignored. In a Markdown cell, lines beginning with #
are treated as header elements (h
tag in HTML). I highly recommend making use of markdown cells for defining #title
and adding a space after the #
sign to have Markdown render that line as a heading.
For example, you can add the following commands to provide "My first post" as the title to your post and to show that post at https://replnotes.com/username/posts/first
# Title: My first post
# url: first
As described above, adding this command to the first cell of your Jupyter notebook sets the title for the post. When the Jupyter notebook is uploaded for creating a new post, the form will be autopopulated with the title specified in the notebook using this command. You can chose to edit the title, but I have found it very useful to keep the title specified in the notebook the same as the title used on REPL Notes to keep track of the changes.
Adding this command to the first cell of the notebook will populate the url
field when creating a new post or editing an old post by uploading a new Jupyter notebook. url
gets used to construct the full URL for the post e.g. https://replnotes.com/username/posts/url
Tags are used to group similar posts together. They are shown in the post preview cards and clicking on one takes the reader to a dedicated landing page that lists all of your posts with that specific tag. Adding #tags: Python, Machine Learning
will add two tags, Python
and Machine Learning
to the post when the file is uploaded. This command also needs to be added to the first cell of the notebook.
The description
field is optional and set by adding a #description
command to the first cell of your notebook. It is only shown in the preview cards for posts and provided to allow the addition of a short description that is tailored to that context. It is not shown in the blog post itself, which renders the title and the visible contents of the notebook.
The image above was embedded using the following code, but the code cell is not visible due to the #hide_input
command added to the first row of the cell.
#hide-input
from IPython.display import Image
Image(filename="bird.jpeg")
Similar to the #hide_input
command, the #hide_output
command may be used as the first row of a cell to hide the output of the code cell. It may be useful when you want to include a code example and want to make sure that it runs successfully, but don't need to show the output to the reader.
The table rendered from the flowers.head()
command in the cell below is hidden due to the #hide_output
command.
from bokeh.sampledata.iris import flowers
flowers.head()
Both the input and the output sections of the cell may be hidden by adding the #hide_cell
command to the first row of any cell. This command allows you to keep your exploratory work for creating the post in the same notebook while ensuring that it is not rendered in the final post. The cell below is hidden, but I guess you will never know what it said.
These commands were inspired by two other Jupyter notebook-related projects: