Markdown examples

You learned in your study of online Jupyter Notebook tutorials that the notebook has Code cells and Markdown cells. Since you knew how to program in Python before enrolling in this course, entering Python code into Code cells is straightforward. You simply enter the code much as you would when writing Python code into a text editor or an IDE.

However, it is not assumed that you knew about Markdown before enrolling in this course. Therefore, this example notebook is provided to help you learn how to write Markdown.

Table of contents

This notebook is relatively large with sections covering a large number of topics. Therefore, the following list of links to the various sections of the notebook is provided to help you navigate among the topics.

The Markdown syntax used to create these links and the associated anchors is explained in Anchor links in markdown. You would do well to study this material so that you will know how to create links to internal anchors in the notebooks that you create.

What is Markdown?

According to Mastering Markdown,

Markdown is a way to style text on the web. You control the display of the document; formatting words as bold or italic, adding images, and creating lists are just a few of the things we can do with Markdown. Mostly, Markdown is just regular text with a few non-alphabetic characters thrown in, like # or *.

The indented block of text that you just read is something called blockquotes in Markdown.

Markdown syntax examples

The following sections contain syntax examples for the most common Markdown components.

You can view the raw Markdown for these examples by downloading the file named Markdown01.ipynb and opening it in your Jupyter Notebook.

Headers

Markdown allows you to create headers of varying sizes much like you would typically see on an HTML web page. In fact, the word Headers that you see above this paragraph is a header.

It is easy to create a header. Just type one or more hashtag # characters and a space at the beginning of a line before a word or group of words. Then terminate the header by advancing to a new line.

The more hashtag characters you type, the smaller will be the header. A single hashtag produces the largest possible header.

Here is an example of several headers. Note that once you reach five hashtag characters, the size of the text doesn't seem to change much but the font automatically changes to Italic. Also note that the limit is six levels of headings. Once you reach seven hashtag characters, the text is no longer rendered as a header. Instead, it is rendered as plain text with seven hashtag characters in the Jupyter Notebook display. (When the notebook is downloaded as HTML and opened in Firefox or Chrome, it is rended as plain text with a single hashtag character showing.)

Large - one hashtag character

Medium - two hashtag characters

Small - three hashtag characters

Tiny - four hashtag characters

Five hashtag characters
Six hashtag characters
# Seven hashtag characters

Italic text

To cause text to be rendered in Italic, surround the text with asterisk characters * or underscore characters _ as shown in the raw Markdown below. Do not leave a space between the asterisk or underscore and the text.

The following text will be displayed as Italic using asterisk characters.

The following text will also be displayed as Italic using underscore characters.

Bold text

To cause text to be rendered as bold, surround the text with double asterisk characters ** or double underscore characters __ as shown in the raw Markdown below. Do not leave a space between the asterisks or underscores and the text.

The following text will be displayed as bold using double asterisk characters.

The following text will also be displayed as bold using double underscore characters.

Bold and Italic text

You can combine the asterisk and underscore characters _**text**_ to cause text to be rendered as both bold and Italic as shown in the raw Markup below.

The following text will be displayed as bold and Italic by combining the asterisk and underscore characters.

Unordered lists

To cause a list of text items to be rendered as an unordered list (sometimes called a bullet list), begin each line of text with an asterisk *, a hyphen (minus) -, or a plus + followed by a space, followed by the text for that item in the list as shown in the raw Markdown below.

To cause items in the list to be indented, begin the indented lines with one or more space characters ahead of the asterisk.

  • Boys
    • Tom
    • Dick
    • Harry
  • Girls
    • Betty
    • Smith girls
      • Suzie Smith
      • Linda Smith
    • Alice
    • Jane

Ordered lists

To cause a list of text items to be rendered as an ordered list, begin each line of text with any number followed by a period, followed by a space, followed by the text for that item in the list as shown in the raw Markdown below.

To cause items in the list to be indented, begin the indented lines with one or more space characters ahead of the number.

It is important to note that the numbers that you use to signify an ordered list are unrelated to the actual numbers and letters that will appear in the ordered list.

  1. Boys
    1. Tom
    2. Dick
    3. Harry
  2. Girls
    1. Betty
    2. Smith girls
      1. Suzie Smith
      2. Linda Smith
    3. Alice
    4. Jane

In creating links, we are often interested in links to anchors internal to the notebook and also in links to resources such as websites external to the notebook.

As mentioned above, the raw Markdown for the Table of contents shows how to create links to anchors internal to the notebook.

There are at least two ways to create links to external resources:

  1. Write the link in Markdown syntax as [name of resource](address of resource)
  2. Write the link in HTML syntax

Markdown syntax

The following is a link to an external resource using the raw Markdown shown below and the first option listed above.

Markdown Cheatsheet

HTML syntax

The following is a link to the same website as above that was created by entering standard HTML syntax into the Markdown.

Markdown Cheatsheet

Also note that the anchors associated with the links in the Table of contents were defined using the second option, HTML syntax.

Blockquotes

A blockquote is an indented block of text as shown in What is Markdown?.

You can create a blockquote by beginning the block of text with a right angle bracket > followed by a space, followed by the text.

Inline code

You can create inline code by surrounding text with back-tick characters. A back-tick character is the backwards sloping apostrophe-like character, typically on the upper-left key on the keyboard, along with the tilde character ~.

I have been using inline code throughout this notebook to show various Markdown control characters such as # * _ and > without having them rendered as control characters. This is a trick that you probably should remember.

Tables

You can create a table of values by typing the column headers on a line separated by vertical bar characters | as shown below.

Then type a line of hyphens - under each column header and separate them by vertical bar characters as shown below but without the blank lines separating the rows.

Then type the content in each cell of the table separating the cells with vertical bar characters as shown below.

Column A | Column B | Column C

-------- | -------- | --------

Cell 1A | Cell 1B | Cell 1C

Cell 2A | Cell 2B | Cell 2C

Cell 3A | Cell 3B | Cell 3C

This syntax will produce the following table.

Column A Column B Column C
Cell 1A Cell 1B Cell 1C
Cell 2A Cell 2B Cell 2C
Cell 3A Cell 3B Cell 3C

You will find more useful information about table formatting at Markdown Cheatsheet.

Strikethrough

At some point, when editing an existing notebook, you might want to strike through some existing text and possibly replace it with new text.

You can strike through text by surrounding the text with double tilde characters like this: ~~strike through this text~~.

This syntax will produce output similar to the following.

The show was enjoyable, but the fireworks were extremely very loud.

Housekeeping material

Author: Prof. Richard G. Baldwin

Affiliation: Professor of Computer Information Technology at Austin Community College in Austin, TX.

File: Markdown01.html

Revised: 05/15/18

Copyright 2018 Richard G. Baldwin