Markdig Cheat Sheet

Published on Sunday, January 8, 2017

Markdig Cheat Sheet

I mentioned in the post Alerts in Wyam that Wyam uses Markdig for Markdown processing, and that Markdig supports extensions. Currently, Markdig lacks documentation. For this reason, I'm going to try and create a “cheat sheet” for the extensions.

Pipe Tables

tag docs
pipetables –or– advanced http://pandoc.org/MANUAL.html#extension-pipe_tables

Code

Right | Left | Default | Center
-----:|:-----|---------|:-----:
12    | 12   | 12      | 12
123   | 123  | 123     | 123
1     | 1    | 1       | 1

Result

Right Left Default Center
12 12 12 12
123 123 123 123
1 1 1 1

Grid Tables

tag docs
gridtables –or– advanced http://pandoc.org/MANUAL.html#extension-grid_tables

Code

+-------+------+---------+--------+
| Right | Left | Default | Center |
+======:+:=====+=========+:======:+
| 12 | 12 | 12 | 12 |
+-------+------+---------+--------+
| 123 | 123 | 123 | 123 |
+-------+------+---------+--------+
| 1 | 1 | 1 | 1 |
+-------+------+---------+--------+

Result 1

Right Left Default Center
12 | 12 | 12 12 |
123 | 123 | 123 | 123 |
1 | 1 1 | 1 |

Extra Emphasis

tag docs
emphasisextras –or– advanced http://pandoc.org/MANUAL.html#strikeout –and– https://markdown-it.github.io/

Code

~~strike through~~ example

~subscript~ example

^superscript^ example

++inserted++ example

==marked== example

Result

strike through example

subscript example

superscript example

inserted example

marked example

Special Attributes

tag docs
attributes –or– advanced https://michelf.ca/projects/php-markdown/extra/#spe-attr

Code

# Header 1 {#header1}

[Link](#header1) back to header1

# Header 2 {.my-class}

# Le Site {lang=fr}

Result 2

Header 1

Link back to header1

Header 2

Le Site

Definition Lists

tag docs
definitionlists –or– advanced https://michelf.ca/projects/php-markdown/extra/#def-list

Code

Apple
: Pomaceous fruit of plants of the genus Malus in 
  the family Rosaceae.

Orange
: The fruit of an evergreen tree of the genus Citrus.

Result 2

Apple : Pomaceous fruit of plants of the genus Malus in the family Rosaceae.

Orange : The fruit of an evergreen tree of the genus Citrus.

Footnotes

tag docs
footnotes –or– advanced https://michelf.ca/projects/php-markdown/extra/#footnotes

Code

This is an example[^3] of footnote usage.

[^3]: An example footnote.

Result

This is an example3 of footnote usage.

Auto-identifiers

tag docs
autoidentifiers –or– advanced http://pandoc.org/MANUAL.html#extension-auto_identifiers

Code

# Automatic Header identifiers

[Link](#automatic-header-identifiers) to header.

Result

Automatic Header identifiers

Link to header.

tag docs
autolinks –or– advanced generates links if a text starts with http:// or https:// or ftp:// or mailto: or www.xxx.yyy

Code

http://digitaltapestry.net

Result

http://digitaltapestry.net

Task Lists

tag docs
tasklists –or– advanced https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments

Code

- [ ] a task list item
- [ ] list syntax required
- [ ] normal **formatting**
- [ ] incomplete
- [x] completed

Result

  • a task list item
  • list syntax required
  • normal formatting
  • incomplete
  • completed

Extra Bullet Lists

tag docs
listextras –or– advanced supporting alpha bullet a. b. and roman bullet (i, ii...etc.)

Code

1. Level 1
    i. Level i
        a. Level a

Result

  1. Level 1
    1. Level i
      1. Level a

Media Support

tag docs
medialinks –or– advanced https://talk.commonmark.org/t/embedded-audio-and-video/441

Code

![Rick Roll](https://www.youtube.com/watch?v=dQw4w9WgXcQ)

Result

Abbreviations

tag docs
abbreviations –or– advanced https://michelf.ca/projects/php-markdown/extra/#abbr

Code

*[HTML]: Hypertext Markup Language

Later in a text we are using HTML and it becomes an abbr tag HTML

Result

Later in a text we are using HTML and it becomes an abbr tag HTML

Citation

tag docs
citations –or– advanced https://talk.commonmark.org/t/referencing-creative-works-with-cite/892

Code

""Tractatus Logico-Philosophicus"" was first published in 1921.

Result

Tractatus Logico-Philosophicus was first published in 1921.

Custom Containers

tag docs
customcontainers –or– advanced https://talk.commonmark.org/t/custom-container-for-block-and-inline/2051

Code

:::{.alert .alert-info}
This is a Bootstrap alert.
:::

Result

This is a Bootstrap alert.

Figures

tag docs
figures –or– advanced https://talk.commonmark.org/t/image-tag-should-expand-to-figure-when-used-with-title/265/5

Code

![Kookburra](/kookaburra.jpg "Kookburra")
![Pelican](/pelican.jpg "Pelican")
![Cheeky looking Rainbow Lorikeet](/lorikeet.jpg "Rainbow Lorikeet")

Result

Kookburra Pelican Cheeky looking Rainbow Lorikeet

Footers

tag docs
footers –or– advanced https://talk.commonmark.org/t/syntax-for-footer/2070

Code

> This is a blockquote
> ^^ This is a ""citation for name""

Result

This is a blockquote

This is a citation for name

Mathematics

tag docs
mathematics –or– advanced https://talk.commonmark.org/t/mathematics-extension/457/31

Code

This is a $math block$

$$
\begin{equation}
  \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
  \label{eq:sample}
\end{equation}
$$

Result 2 4

This is a \(math block\)

\[ \begin{equation} \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15} \label{eq:sample} \end{equation} \]

Emoji

tag docs
emojis https://markdown-it.github.io/

Code

It's easy to use emojis. ;) That's cool! 8-)

Result

It's easy to use emojis. 😉 That's cool! 😎

SmartyPants

tag docs
smartypants https://daringfireball.net/projects/smartypants/

Code

This is a "text"

This is a 'text'

This is a <<text>>

This is a "text

This is a "text 'with" a another text'

This is a -- text

This is a --- text

This is a en ellipsis...

Result

This is a “text”

This is a ‘text’

This is a «text»

This is a "text

This is a “text 'with” a another text'

This is a – text

This is a — text

This is a en ellipsis…

Diagrams

tag docs
diagrams –or– advanced https://knsv.github.io/mermaid/

Code

    ```mermaid
    graph TD;
        A-->B;
        A-->C;
        B-->D;
        C-->D;
    ```

Result 2 5

graph TD; A-->B; A-->C; B-->D; C-->D;


  1. Alignment doesn't appear to be working, and I don't now why.

  2. Not all results are visibly evident with the current styling. View the HTML produced.

  3. An example footnote.

  4. I'll be honest, I don't understand the use case for this one.

  5. This needs mermaid.css and mermaid.js to be linked. I've done so here, but the way you do it will be improved the next release, so I'll wait to blog about that. Not sure why the generated diagram here is missing the arrow lines, but I don't believe it's got anything to do with Wyam or Markdig. Update: Turns out I had a typo in my link tag for the CSS that caused the display issue. Doh! Also, adding the necessary CSS and JS is relatively easy now. Add a _Header.cshtml with any CSS links you want, and _Scripts.cshtml for the scripts. You can view the source for this site to see it for yourself: https://github.com/wekempf/wekempf.github.io/.

comments powered by Disqus