Markdown cheatsheet
Steve Martinelli
by Steve Martinelli

Tags

  • markdown

Attribution of this content goes to the folks at so-simple: https://github.com/mmistakes/so-simple-theme

Enable table of contents on post or page by adding {% include toc %} where you’d like it to appear.

Table of Contents

  1. Header one
    1. Header two
      1. Header three
        1. Header four
          1. Header five
            1. Header six
    2. Blockquotes
    3. Tables
    4. Definition Lists
    5. Unordered Lists (Nested)
    6. Ordered List (Nested)
    7. Buttons
    8. Notices
    9. Address element
    10. Anchor element (aka. Link)
    11. Abbreviation element
    12. Cite element
    13. Code element
    14. Strike element
    15. Emphasize element
    16. Insert element
    17. Keyboard element
    18. Preformatted element
    19. Quote element
    20. Strong element
    21. Subscript element
    22. Superscript element
    23. Variable element
    24. Twitter embeds
  2. Syntax highlighting
    1. GFM Code Blocks
    2. Jekyll Highlight Liquid Tag
    3. Code Blocks in Lists
    4. GitHub Gist Embed
  3. Hero image

A variety of common HTML elements to demonstrate the theme’s stylesheet and verify they have been styled appropriately.

Header one

Header two

Header three

Header four

Header five
Header six

Blockquotes

Single line blockquote:

Stay hungry. Stay foolish.

Multi line blockquote with a cite reference:

People think focus means saying yes to the thing you’ve got to focus on. But that’s not what it means at all. It means saying no to the hundred other good ideas that there are. You have to pick carefully. I’m actually as proud of the things we haven’t done as the things I have done. Innovation is saying no to 1,000 things.

Steve Jobs — Apple Worldwide Developers' Conference, 1997

Quoted text inline using <q> element:

Luke continued, And then she called him a scruffy-looking nerf-herder! I think I’ve got a chance! The poor naive fool…

Tables

Employee Salary  
John Doe $1 Because that’s all Steve Jobs needed for a salary.
Jane Doe $100K For all the blogging she does.
Fred Bloggs $100M Pictures are worth a thousand words, right? So Jane × 1,000.
Jane Bloggs $100B With hair like that?! Enough said.
Header1 Header2 Header3
cell1 cell2 cell3
cell4 cell5 cell6
cell1 cell2 cell3
cell4 cell5 cell6
Foot1 Foot2 Foot3

Definition Lists

Definition List Title
Definition list division.
Startup
A startup company or startup is a company or temporary organization designed to search for a repeatable and scalable business model.
#dowork
Coined by Rob Dyrdek and his personal body guard Christopher “Big Black” Boykins, “Do Work” works as a self motivator, to motivating your friends.
Do It Live
I’ll let Bill O’Reilly explain this one.

Unordered Lists (Nested)

  • List item one
    • List item one
      • List item one
      • List item two
      • List item three
      • List item four
    • List item two
    • List item three
    • List item four
  • List item two
  • List item three
  • List item four

Ordered List (Nested)

  1. List item one
    1. List item one
      1. List item one
      2. List item two
      3. List item three
      4. List item four
    2. List item two
    3. List item three
    4. List item four
  2. List item two
  3. List item three
  4. List item four

Buttons

Make any link standout more when applying the .btn class.

<a href="#" class="btn--success">Success Button</a>

Default Button Primary Button Success Button Warning Button Danger Button Info Button Inverse Button Light Outline Button

[Default Button Text](#link){: .btn}
[Primary Button Text](#link){: .btn .btn--primary}
[Success Button Text](#link){: .btn .btn--success}
[Warning Button Text](#link){: .btn .btn--warning}
[Danger Button Text](#link){: .btn .btn--danger}
[Info Button Text](#link){: .btn .btn--info}
[Inverse Button](#link){: .btn .btn--inverse}
[Light Outline Button](#link){: .btn .btn--light-outline}

X-Large Button Large Button Default Button Small Button

[X-Large Button](#link){: .btn .btn--primary .btn--x-large}
[Large Button](#link){: .btn .btn--primary .btn--large}
[Default Button](#link){: .btn .btn--primary }
[Small Button](#link){: .btn .btn--primary .btn--small}

Notices

Watch out! This paragraph of text has been emphasized with the {: .notice} class.

Watch out! This paragraph of text has been emphasized with the {: .notice--primary} class.

Watch out! This paragraph of text has been emphasized with the {: .notice--info} class.

Watch out! This paragraph of text has been emphasized with the {: .notice--warning} class.

Watch out! This paragraph of text has been emphasized with the {: .notice--success} class.

Watch out! This paragraph of text has been emphasized with the {: .notice--danger} class.

Address element

1 Infinite Loop
Cupertino, CA 95014
United States

This is an example of a link.

Abbreviation element

The abbreviation CSS stands for “Cascading Style Sheets”.

Cite element

“Code is poetry.” —Automattic

Code element

You will learn later on in these tests that word-wrap: break-word; will be your best friend.

Strike element

This element will let you strikeout text.

Emphasize element

The emphasize element should italicize text.

Insert element

This element should denote inserted text.

Keyboard element

This scarcely known element emulates keyboard text, which is usually styled like the <code> element.

Preformatted element

This element styles large blocks of code.

.post-title {
	margin: 0 0 5px;
	font-weight: bold;
	font-size: 38px;
	line-height: 1.2;
	and here's a line of some really, really, really, really long text, just to see how the PRE element handles it and to find out how it overflows;
}

Quote element

Developers, developers, developers… –Steve Ballmer

Strong element

This element shows bold text.

Subscript element

Getting our science styling on with H2O, which should push the “2” down.

Superscript element

Still sticking with science and Isaac Newton’s E = MC2, which should lift the 2 up.

Variable element

This allows you to denote variables.

Twitter embeds



Syntax highlighting

GFM Code Blocks

GitHub Flavored Markdown fenced code blocks are supported by default with Jekyll. You may need to update your _config.yml file to enable them if you’re using an older version.

kramdown:
  input: GFM

Yet another code snippet for demonstration purposes:

module Jekyll
  class TagIndex < Page
    def initialize(site, base, dir, tag)
      @site = site
      @base = base
      @dir = dir
      @name = 'index.html'
      self.process(@name)
      self.read_yaml(File.join(base, '_layouts'), 'tag_index.html')
      self.data['tag'] = tag
      tag_title_prefix = site.config['tag_title_prefix'] || 'Tagged: '
      tag_title_suffix = site.config['tag_title_suffix'] || '&#8211;'
      self.data['title'] = "#{tag_title_prefix}#{tag}"
      self.data['description'] = "An archive of posts tagged #{tag}."
    end
  end
end

Jekyll Highlight Liquid Tag

Jekyll also has built-in support for syntax highlighting of code snippets using either Rouge or Pygments, using a dedicated Liquid tag as follows:

{% highlight scss %}
.highlight {
  margin: 0;
  padding: 1em;
  font-family: $monospace;
  font-size: $type-size-7;
  line-height: 1.8;
}
{% endhighlight %}

And the output will look like this:

.highlight {
  margin: 0;
  padding: 1em;
  font-family: $monospace;
  font-size: $type-size-7;
  line-height: 1.8;
}

Here’s an example of a code snippet using the Liquid tag and linenos enabled.

1
2
3
4
5
6
7
8
<nav class="pagination" role="navigation">
  {% if page.previous %}
    <a href="{{ site.url }}{{ page.previous.url }}" class="btn" title="{{ page.previous.title }}">Previous article</a>
  {% endif %}
  {% if page.next %}
    <a href="{{ site.url }}{{ page.next.url }}" class="btn" title="{{ page.next.title }}">Next article</a>
  {% endif %}
</nav><!-- /.pagination -->

Code Blocks in Lists

Indentation matters. Be sure the indent of the code block aligns with the first non-space character after the list item marker (e.g., 1.). Usually this will mean indenting 3 spaces instead of 4.

  1. Do step 1.
  2. Now do this:

    def print_hi(name)
      puts "Hi, #{name}"
    end
    print_hi('Tom')
    #=> prints 'Hi, Tom' to STDOUT.
    
  3. Now you can do this.

GitHub Gist Embed

GitHub Gist embeds can also be used:

<script src="https://gist.github.com/mmistakes/77c68fbb07731a456805a7b473f47841.js"></script>

Which outputs as:


Hero image

Add a horizontal image using the following YAML Front Matter:

image:
  path: /images/eder-oliveira-180877.jpg

Hero images can also be assigned more succinctly when thumbnail or caption are not used.

image: /images/eder-oliveira-180877.jpg

Tall images will push content down the page. 1600 x 600 is a good middle-ground size to aim for.