gray
red
blue
green
purple
All Markdown Syntax
All Markdown Syntax
by WZhang published 2026-02-02 views 141

All Markdown Syntax

Abstract: This is a test blog and almost all markdown syntaxes are include in it.

Two purposes for:

  1. as a reference to learn markdown syntax.
  2. as a original Markdown to check the render effect by converting to HTML format.


0. Outline

Use [TOC]

[TOC]

💥 mistune module use .. toc::, and max-level <= 3


1. Headings

Use # Heading level 1, Use ## Heading level 2


Use ### Heading level 3

1.1 Heading level 3


Use #### Heading level 4

1.1.1 Heading level 4


Use ##### Heading level 5

1.1.1.1 Heading level 5


Use ###### Heading level 6

1.1.1.1.1 Heading level 6


2. Emphasis

Use *italic text*

italic text


Use **bold text**

bold text


Use ***bold and italic text***

bold and italic text


3. Links and Images

links:

Use [ALT](URL)

github.com


Images-1(original):

Use ![ALT](image URL)

github logo


image-2(using html tag):

Use <img src=URL alt=ALT style=""/>

github logo


4. Code

inline code

Use `code`

inline code looks like this: print("hello world")


code block

Use ```coding language or just ```, then press the [Enter] key

#include <stdio.h>
int main() {
   printf("Hello, markdown!\nHello, html!");
   return 0;
}



5. Math

inline math

Use $math$

Inline math looks like this: \(E_0=mc^2\)


math block

Use $$, then press the [Enter] key

$$ e^{\pi i}+1=0 $$


6. Blockquote

Use > quote text(level 1), > > quote text(level 2), and so on.

only quote

Quote level 1

Quote level 2

Quote level 3

Quote level 2

Quote level 1


  • only quote with multipe paragraphs

Paragraphs 1

Paragraphs 2


add other elements

  • Add emphasis text

italic text

blod text

italic and blod text


  • Add List element
  1. order list[1]
    1. Order list[1-1]
    2. Order list[1-2]
  • Unorder list[1]
    • Unorder llist[1-1]
    • Unorder list[1-2]


  • Add code or code block

inline code 1: print("hello markdown")

Inline code 2: print("hello html")

code block1:

print("hello markdown!\nhello html!")

code block2:

#include <stdio.h>
int main() {
printf("Hello, markdown!\nHello, html!");
return 0;
}


  • Add link or image

Link 1: gitbub.com

Link 2: bing

Img link1:

github logo

img link2:

github logo


  • Add math

Inline math1: \(E_0=mc^2\)

Inline math2: \(e^{\pi i}+1=0\)

Math block 1: $$ e^{\pi i} + 1=0 $$

Math block 2: $$ E_0 = mc^2 $$


7. Lists

ordered lists

Use 1. Item, then press the [Enter] key. and press [Tab] to increase list indent.

  1. Item[1]
    1. Item[1-1]
      1. Item[1-1-1]
    2. Item[1-2]
  2. Item[2]


unordered lists

Use * Item or - Item or + Item, then press the [Enter] key. and press [Tab] to increase list indent.

  • Item[1]
    • Item[1-1]
      • Item[1-1-1]
    • Item[1-2]
  • Item[2]


ordered and unordered lists

  1. Item[1]

    1. Item[1-1]
      • Item[1-1-1]
    • Item[1-2]
  • Item[2]


add paragraphs

  1. Item[1]

    Paragraph 1

    1. Item[1-1]

      Paragraph 2


add emphasis

  1. italic item[1]

    italic text

    1. bold item[1-1]

      bold text

      1. italic and bold item[1-1-1]

        italic and bold text

add blockquote

  1. Item[1]

    Blockquote 1

    1. Item[1-1]

      Blockquote 2


add code or code blocks

  1. Inline code[1]: print("hello markdown")

    print("hello world")

    1. Inline code[1-1]: print("hello markdown")

      print("hello html")

    2. code block 1

      print("hello markdown!\nhello html!")
      
  2. code block 2

    #include <stdio.h>
    int main() {
       printf("Hello, markdown!\nHello, html!");
       return 0;
    }
    


add links or images

  1. Link 1

    gitbub.com

    1. Link 2: bing

    2. Img link1

      github logo

  2. img link2:github logo


add math

  1. Inline math[1] \(E_0=mc^2\) $$ e^{\pi i}+1=0 $$

    1. Inline math[2]

      Math: \(e^{\pi i}+1=0\)

    2. math block $$ E=mc^2 $$


8. Tables

Use |col-1|col-2|col-3|, Align text by adding |:---|:---:|---:|(to left, to center, to right)

table with alignment

align to left center align to right


add other elements

Elements Outputs
add links looks like this: github.com
add image looks like this: github logo
add code looks like this: print("hello world")
add emphasis Looks like this: italic text, bold text , itelic and bold text
add linebreak First line.
And second line.
add math looks like this: \(E=mc^2\)
Unavailable elements headings, code block, math block, blockquote, list, table


9. others

line breaks

Use <br>

This is the first line.
And this is the second line.


horizontal line

Use ---

horizontal line looks like this:



highlight

Use ==highlight text==

Highlight looks like this: highlight text


underline

Use <u>underline text</u>

Underline looks like this: underline text


strikethrough

Use ~~strikethrough text~~

strikethrough text


subscript

Use H~2~0

subscript looks like this: H20


superscript

Use x^2^

Superscript looks like this: x2


footnotes

Use [^1] and [^1]:

Here is a simple footnote1 .


heading ids

Use {#custom-id}

Heading IDs example {#custom-id}

linking to heading ids by: Heading IDs example


task lists

Use - [X]

  • Task 1
  • Task 2


emoji

Use &#x1F602;

That is so funny! 😂


* About mistune

Introduction

A fast yet powerful Python Markdown parser with renderers and plugins, compatible with sane CommonMark rules.

See 1. Offical website: Mistune or 2. Github project: lepture/mistune


Comparison of the speeds of related Python Markdown parser. ( Data from Github: lepture/mistune )

/ Parser ➡ Case ⬇ mistune (3.0.0) mistune (slow) mistune (fast) mistune (full) markdown (3.3.7) markdown2 (2.4.3) mistletoe (0.8.2) markdown_it (2.1.0)
atx 13.90 13.12 13.25 15.45 48.41 379.31 25.46 42.38
setext 8.43 8.98 8.12 9.53 30.75 218.91 20.47 27.01
normal_ul 60.91 59.70 60.41 62.89 83.79 175.36 74.82 103.01
insane_ul 104.19 105.83 103.04 105.80 133.83 337.24 122.10 85.93
normal_ol 25.10 25.32 25.11 25.95 43.30 75.88 33.64 40.31
insane_ol 46.20 49.15 45.97 47.54 50.15 210.49 84.08 83.62
blockquote 15.48 16.13 15.35 16.10 63.04 702.44 28.56 37.35
blockhtml 7.90 7.08 7.41 8.56 46.66 122.10 12.24 26.84
fenced 4.28 4.09 4.02 4.45 33.84 92.49 9.19 12.50
paragraph 95.94 561.28 93.60 110.10 304.13 267.85 779.32 825.52
emphasis 23.59 16.93 23.23 25.28 76.50 9.39 33.69 60.91
auto_links 3.80 3.39 3.66 3.92 23.05 6.54 8.36 19.73
std_links 21.92 17.49 19.88 24.51 39.12 14.52 22.85 32.61
ref_links 47.67 39.45 44.82 52.38 87.66 23.12 59.14 80.45
readme 56.61 68.82 53.86 61.26 211.03 533.41 110.13 247.99


A example of converting from Markdown to HTML

import mistune

# extended plugins
from mistune.plugins.formatting import strikethrough # 删除线
from mistune.plugins.footnotes import footnotes # 脚注
from mistune.plugins.table import table # 表格 !important
from mistune.plugins.url import url # 自动 url
from mistune.plugins.task_lists import task_lists # 任务列表
from mistune.plugins.formatting import mark # 高亮
from mistune.plugins.formatting import superscript # 上标
from mistune.plugins.formatting import subscript # 下标
from mistune.plugins.math import math # 公式 !important
from mistune.directives import RSTDirective, TableOfContents # 目录 !important

# read markdown
with open("All Markdown syntax.md", "r", encoding="utf-8") as fp:
	mkdown_txt = ".. toc::\n" + fp.read().replace("\n[toc]\n", "\n").replace("\n[TOC]\n", "\n") # 开头自动添加目录

# convert
renderer = mistune.HTMLRenderer(escape=False)
markdown = mistune.create_markdown(renderer, plugins=[strikethrough, footnotes, table, url, task_lists, mark,\
                                                      superscript, subscript, math, RSTDirective([TableOfContents()])])
html_txt = markdown(mkdown_txt)

# write html
with open("output.html", "w", encoding="utf-8") as fp:
	fp.write(html_txt)
  

Notes: !important is recommended.


Invalid syntax to mistune

  • (escape=True) HTML tag: <img />, <br>, <u></u>

  • (escape=True) Blockquote with multiple paragraphs

  • Math block with indent

  • Heading IDs

  • Emoji

  1. This is the first footnote.

2comment(s)
x )
2026-02-09 22:04:45
cool
x )
Alex
2026-02-02 22:49:23
Hello world. Just a test.