What is Markdown? Markdown is a human readable syntax (also referred to as a markup language) for formatting text documents.Markdown can be used to produce nicely formatted documents including PDFs and web pages. When you format text using Markdown in a document, it is similar to using the format tools (e.g. Bold, heading 1, heading 2) in a word processing tool like Microsoft Word or Google. What is Markdown? Colab has two types of cells: text and code. Text cells are formatted using a simple markup language called Markdown. To see the Markdown source, double-click a text cell, showing both the Markdown source and the rendered version. Above the Markdown.
Info to help convert the Jupyter notebooks we use in class into blog posts for your github blog. Manual conversion instructions are given for one-off posts, as well as detials to make a bash alias to automate the conversion process, move the files, and update your blog in one fell swoop.
Run the following command in terminal to convert the file named notebook.ipynb
from Jupyter notebook format to a markdown file suitable for your Jekyll blog. Note this must be run in the terminal inside the directory that includes the file you intend to convert.
That command will run the translation utility provided by Jupyter and create two new items:
notebook.md
is a new file containing the markdown for your new blog postnotebook_files
is a new folder containing all the images for your new blog postMove the notebook.md
file to your blog’s _posts
folder and rename it to include the date and title for your post. You will also want to make sure the first few lines contain the appropriate front matter (YAML block in Jekyll parlance). You will also need to change any image links to point to your blog’s image folder. Read below to see my tool for automating most of these tasks.
Move the notebook_files
folder to your blog’s “images” folder (this is also automated in my tool below).
Add these files to the git repository and commit. Then push the repo up to the server. Congratulations, your updated site should be live within a few minutes!
new_post notebook.ipynb
(where notebook.ipynb is the name of the file you wish to convert and post)There are currently no sanity checks in place in this function, so please take care to understand how it works before you run it, and be careful what you use it on. I have made an example post
This process is very similar to the tool I created in the first week of the class. Basically we are adding a shortcut to our .bash_profile
script that the CLI loads everytime we open a new terminal window. I call my shortcut new_post
but you can change this to whatever command you want to type when you post a notebook to your blog. The installation is easy, just copy and paste the code below into your ~/.bash_profile
file (you can use the command subl ~/.bash_profile
to open this file in Sublime Text directly from the CLI). Do note that you will need to change the info on the first few lines to reflect how your personal computer is setup.
When you set up your system for translating the blog posts, you will need to add some CSS code to your html template file to tell Jekyll to format the Pandas DataFrame tables appropraitely. Below is the relevant section of my <username>.github.io/_layouts/default.html
file that has the CSS code included at the end of the <head>
section. You should edit the your defualts file to be similar.
Here is a quick overview of the features in the added CSS code. You can change any of these settings to suit your fancy.
#b8d1f3
)