Python Markdown Cheat Sheet
Reading time: 25 minutes
- Python Jupyter Markdown Cheat Sheet
- Python Markdown Cheat Sheet
- Python Markdown Cheat Sheet
- Markdown Cheatsheet Github
- Python Markdown Tutorial
Markdown is a simple lightweight markup language which is widely used as a formatting language on the web. Few points that make markdown a wonderful option are:
- Simple text format hence, easy to learn and use
- convertible to various formats
In short, markdown data is converted to HTML data using the markdown processor which is in turn rendered by the browser. Markdown files have .md extension.
In this article, we will walk you through the basic Markdown elements so that you can use them smoothly anywhere anytime.
Heading
Markdown is a way to style text on the web. You control the display of the document; forma˜ing 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. Sometimes markdown doesn’t make line breaks when you want them. To force a linebreak, use the following code: Indenting Use the greater than sign followed by a space, for example: Text that will be indented when the Markdown is rendered. Any subsequent text is indented until the next carriage return.
- Python-Markdown provides two public functions (markdown.markdown and markdown.markdownFromFile) both of which wrap the public class markdown.Markdown.If you’re processing one document at a time, these functions will serve your needs.
- In case you’re interested, we also have complete cheat sheets for Bootstrap, HTML, CSS, MySQL, and JavaScript. So download a copy of our Python cheat sheet and get that first.py program up and running! PDF Version of Python Cheat Sheet. Python Cheat Sheet (Download PDF) Infographic Version of Python Cheat Sheet (PNG) Python Cheat Sheet.
For heading of various sizes, use the following:
The above markdown is rendered as follows:
heading2
heading3
heading4
Text formatting
Bold text
To bold a text, wrap it in ** from both sides. For example, the following markdown:
is rendered as:
I love OpenGenus
Italics
To italicize a text, wrap it in * from both sides. For example, the following markdown:
is rendered as:
I love OpenGenus
Python Jupyter Markdown Cheat Sheet
Strikethrough
To strikethrough a text, wrap it in ~~ from both sides. For example, the following markdown:
is rendered as:
Python Markdown Cheat Sheet
I like love OpenGenus

Highlight
To highlight a text, wrap it in from both sides. For example, the following markdown:
is rendered as:
I love OpenGenus
Quote
To quote a text, use > infront of the text. For example, the following markdown:
is rendered as:
I love OpenGenus
List
To define an unordered list, use the following markdown:
Python Markdown Cheat Sheet
The above markdown is rendered as follows:
- data 1
- data 2
- data 3
To define an ordered list, use the following markdown:
The above markdown is rendered as follows:
- data 1
- data 2
- data 3
To define a sub list, use the following markdown:
The above markdown is rendered as follows:
- data 1
- data 2
- data 21
- data 22
- data 3
Table
To define a simple table in markdown, use the following:
The above markdown is rendered as follows:
| heading1 | heading2 | heading3 |
|---|---|---|
| data11 | data 12 | data 13 |
| data 21 | data 2 2 | data 23 |
Links
We can define a link in Markdown as follows:
The above markdown is rendered as:
Images
You can add images with a path https://iq.opengenus.org/content/images/2019/03/opengenus-1.png as:
The above image is rendered as:
Code
To add code in Markdown, use the following:
It will be rendered as:
Mixing HTML
You can add HTML elements in Markdown and it will work smoothly
On adding markdown elements in HTML, you will see that some elements are rendered correctly but not all.
So, you can use a mix of HTML and Markdown in a single document but you may avoid mixing HTML and Markdown in a single DOM element.
This is a Python implementation of John Gruber’sMarkdown.It is almost completely compliant with the reference implementation,though there are a few very minor differences. See John’sSyntax Documentationfor the syntax rules.
To get started, see the installation instructions, the libraryreference, and the command line interface.
Goals¶
Markdown Cheatsheet Github
The Python-Markdown project is developed with the following goals in mind:
Maintain a Python library (with an optional CLI wrapper) suited to use in web server environments (never raise an exception, never write to stdout, etc.) as an implementation of the markdown parser that follows the syntax rules and the behavior of the original (markdown.pl) implementation as reasonably as possible (see differences for a few exceptions).
Provide an Extension API which makes it possible to change and/or extend the behavior of the parser.
Python Markdown Tutorial
Features¶
In addition to the basic markdown syntax, Python-Markdown supports the followingfeatures:
International Input
Python-Markdown will accept input in any languagesupported by Unicode including bi-directional text. In fact the test suiteincludes documents written in Russian and Arabic.
Extensions
Various extensions are provided (includingextra) to change and/or extend the base syntax.Additionally, a public Extension API is availableto write your own extensions.
Output Formats
Python-Markdown can output documents with either HTML or XHTML style tags.See the Library Reference for details.
Command Line Interface
In addition to being a Python Library, acommand line script is available for your convenience.
Differences¶
While Python-Markdown strives to fully implement markdown as described in thesyntax rules, the rulescan be interpreted in different ways and different implementationsoccasionally vary in their behavior (see theBabelmark FAQfor some examples). Known and intentional differences found in Python-Markdownare summarized below:
Middle-Word Emphasis
Python-Markdown defaults to ignoring middle-word emphasis (and strongemphasis). In other words,
some_long_filename.txtwill not becomesome<em>long</em>filename.txt. This can be switched off if desired. Seethe Legacy EM Extension for details.Indentation/Tab Length
The syntax rulesclearly state that when a list item consists of multiple paragraphs, “eachsubsequent paragraph in a list item must be indented by either 4 spacesor one tab” (emphasis added). However, many implementations do not enforcethis rule and allow less than 4 spaces of indentation. The implementers ofPython-Markdown consider it a bug to not enforce this rule.
This applies to any block level elements nested in a list, includingparagraphs, sub-lists, blockquotes, code blocks, etc. They must alwaysbe indented by at least four spaces (or one tab) for each level of nesting.
In the event that one would prefer different behavior,tab_length can be set to whatever length isdesired. Be warned however, as this will affect indentation for all aspectsof the syntax (including root level code blocks). Alternatively, a third party extension may offer a solution that meets your needs.
Consecutive Lists
While the syntax rules are not clear on this, many implementations (includingthe original) do not end one list and start a second list when the list marker(asterisks, pluses, hyphens, and numbers) changes. For consistency,Python-Markdown maintains the same behavior with no plans to change in theforeseeable future. That said, the Sane List Extensionis available to provide a less surprising behavior.
Support¶

You may report bugs, ask for help, and discuss various other issues on the bug tracker.
