﻿---
title: "Markdown Syntax Feature Reference"
date: "2026-06-10"
tags:
  - markdown
  - commonmark
  - gfm
  - syntax
  - reference
abstract: >
  A comprehensive Markdown reference document focused on syntax itself.
  Covers standard Markdown, CommonMark behavior, GitHub Flavored Markdown,
  inline HTML, math, diagrams, tables, footnotes, admonitions, metadata,
  and editor-relevant edge cases.
---

# Markdown Syntax: Extended Feature Reference

[![Syntax](https://img.shields.io/badge/topic-markdown-blue)](https://daringfireball.net/projects/markdown/)
[![Flavor](https://img.shields.io/badge/flavor-CommonMark%20%2B%20GFM-green)](https://github.github.com/gfm/)

> **Purpose:** This file is a broad Markdown syntax reference and feature stress test.
> It focuses on Markdown itself rather than a subject-matter theme.

## Table of Contents

- [1. Introduction](#1-introduction)
- [2. Basic Markdown Features](#2-basic-markdown-features)
- [3. Headings and Document Structure](#3-headings-and-document-structure)
- [4. Inline Syntax](#4-inline-syntax)
- [5. Links and Images](#5-links-and-images)
- [6. Lists and Nesting](#6-lists-and-nesting)
- [7. Blockquotes and Admonitions](#7-blockquotes-and-admonitions)
- [8. Code Blocks and Source Examples](#8-code-blocks-and-source-examples)
- [9. Tables](#9-tables)
- [10. Math and Technical Notation](#10-math-and-technical-notation)
- [11. Diagrams](#11-diagrams)
- [12. Advanced Markdown](#12-advanced-markdown)
- [13. HTML Inside Markdown](#13-html-inside-markdown)
- [14. CommonMark and GFM Edge Cases](#14-commonmark-and-gfm-edge-cases)
- [15. Reference Material](#15-reference-material)
- [Appendix A: Stress Tests](#appendix-a-stress-tests)

---

## 1. Introduction

Markdown is a lightweight plain-text markup language designed to be readable in
source form while still converting cleanly to structured output such as HTML.

Different environments support different subsets or extensions:

1. **Original Markdown** emphasizes readability and simple prose formatting.
2. **CommonMark** defines a more precise, interoperable parsing specification.
3. **GitHub Flavored Markdown (GFM)** adds tables, task lists, strikethrough,
   autolinks, and related conveniences.
4. **Editor-specific extensions** may add math, diagrams, callouts, footnotes,
   front matter, and raw HTML preview.

This document is intentionally broad. It is both:

- a syntax reference
- a rendering test
- an editor behavior check
- a source-format stress file

The **high-level Markdown workflow** is:

```text
Plain text source -> Parser -> Abstract structure -> Renderer -> Output
         ^                                                    |
         |                                                    v
   Human-readable editing <- Round-trip compatibility <- Export / Preview
```

---

## 2. Basic Markdown Features

### 2.1 Paragraphs

A paragraph is simply text separated from surrounding text by blank lines.

Markdown usually treats consecutive lines as part of the same paragraph until a
blank line or a block boundary appears.

This paragraph is separate from the one above.

### 2.2 Hard and Soft Line Breaks

This line ends with two spaces.  
So this appears on a new rendered line.

This line
may remain part of the same paragraph in many renderers because it uses only a
soft break in the source.

### 2.3 Horizontal Rules

Three common thematic break forms:

---

***

___

### 2.4 Escaping Markdown Characters

Markdown punctuation can be escaped:

\*not italic\*  
\# not a heading  
\`not inline code\`  
\[not a link\](#not-a-link)

### 2.5 Comments About Readability

A good Markdown source file should remain understandable even before it is
rendered. That is one of its strongest practical advantages.

---

## 3. Headings and Document Structure

### 3.1 ATX Headings

# Level 1 Heading Example

## Level 2 Heading Example

### Level 3 Heading Example

#### Level 4 Heading Example

##### Level 5 Heading Example

###### Level 6 Heading Example

### 3.2 Setext Headings

Level 1 Setext Heading
======================

Level 2 Setext Heading
----------------------

### 3.3 Structural Conventions

Typical heading usage:

1. One `#` heading for the document title.
2. `##` headings for major sections.
3. `###` headings for subsections.
4. Deeper levels only when necessary.

### 3.4 Internal Heading Links

- [Jump to tables](#9-tables)
- [Jump to edge cases](#14-commonmark-and-gfm-edge-cases)
- [Jump to appendix](#appendix-a-stress-tests)

---

## 4. Inline Syntax

### 4.1 Emphasis

- *italic text*
- **bold text**
- ***bold italic text***
- ~~strikethrough~~
- `inline code`

### 4.2 Inline Code

Use backticks for short literals such as `README.md`, `Ctrl+Shift+P`, `# Heading`,
or `npm run dev`.

### 4.3 Mixed Inline Formatting

Markdown can mix styles, for example:

- **bold with `inline code` inside**
- *italic with a [link](https://commonmark.org/) inside*
- ~~obsolete `syntax`~~

### 4.4 Highlight Extensions

Some renderers support ==highlighted text==.

### 4.5 Superscript and Subscript

If HTML is allowed:

- E = mc<sup>2</sup>
- H<sub>2</sub>O
- x<sub>n+1</sub>

### 4.6 Keyboard Tags

<kbd>Ctrl</kbd> + <kbd>K</kbd>  
<kbd>Alt</kbd> + <kbd>Shift</kbd> + <kbd>E</kbd>

### 4.7 Emoji and Shortcodes

Unicode emoji: 📄 ✍️ 🔗 ✅

Some environments also recognize shortcodes such as `:memo:` or
`:white_check_mark:`.

---

## 5. Links and Images

### 5.1 Inline Links

- [CommonMark](https://commonmark.org/)
- [GitHub Flavored Markdown Spec](https://github.github.com/gfm/)
- [Jump to code blocks](#8-code-blocks-and-source-examples)

### 5.2 Reference-Style Links

- [Markdown Guide][markdown-guide]
- [GitHub Docs][github-docs]

[markdown-guide]: https://www.markdownguide.org/
[github-docs]: https://docs.github.com/

### 5.3 Autolinks

- <https://commonmark.org/help/>
- <https://github.github.com/gfm/>
- <mailto:someone@example.com>

Bare URLs may also auto-link in GFM:

https://example.com/path?q=markdown

### 5.4 Titles on Links

[Spec with title](https://spec.commonmark.org/ "CommonMark Specification")

### 5.5 Images

![Markdown mark](https://upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg)

### 5.6 Image With Title

![Syntax illustration](https://upload.wikimedia.org/wikipedia/commons/8/84/Example.svg "Example image")

### 5.7 Reference Image

![Markdown logo][markdown-logo]

[markdown-logo]: https://upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg

---

## 6. Lists and Nesting

### 6.1 Unordered Lists

- dash item
- another item
- item with children
  - nested item
  - another nested item
    - deeper nesting

### 6.2 Ordered Lists

1. first
2. second
3. third

Markdown often renumbers automatically on render, so source may also use:

1. one
2. still renders as two
3. still renders as three

### 6.3 Mixed Lists

1. Document sections
   - headings
   - paragraphs
   - lists
2. Inline formatting
   - emphasis
   - code
   - links

### 6.4 Task Lists

- [x] headings
- [x] paragraphs
- [x] links
- [ ] revise examples
- [ ] add more renderer edge cases

### 6.5 Definition Lists

Markdown
: A lightweight markup language.

CommonMark
: A formal specification for Markdown parsing.

GFM
: GitHub Flavored Markdown.

### 6.6 Continuation Paragraphs

- List item with a continuation paragraph.

  This paragraph belongs to the list item above because it is indented beneath
  that item.

- Another list item.

  > This quoted block also belongs to the list item because it is nested inside it.

### 6.7 Ordered and Unordered Marker Variants

- dash marker
* asterisk marker
+ plus marker
1. numbered marker
2. continues numbering

---

## 7. Blockquotes and Admonitions

### 7.1 Simple Blockquote

> Markdown source is valuable because it stays readable before rendering.

### 7.2 Multi-Paragraph Blockquote

> This is the first paragraph in a blockquote.
> 
> This is the second paragraph in the same blockquote.

### 7.3 Nested Blockquote

> Outer quote.
> 
> > Inner quote.
> 
> Back to the outer level.

### 7.4 GitHub-Style Admonitions

> [!NOTE]
> A note callout is useful for neutral supporting information.

> [!TIP]
> A tip callout is useful for best practices and shortcuts.

> [!IMPORTANT]
> Important callouts emphasize something the reader should not miss.

> [!WARNING]
> Warning callouts indicate risk, incompatibility, or likely confusion.

> [!CAUTION]
> Caution callouts are suitable for potentially destructive or misleading actions.

> [!BUG]
> Bug callouts are suitable for known defects, incorrect behavior, or implementation limitations.

### 7.5 Custom Summary-Like Admonition

> [!SUMMARY]
> Some renderers may treat unknown alert types as ordinary blockquotes or custom
> callouts rather than canonical GitHub alerts.

---

## 8. Code Blocks and Source Examples

### 8.1 Fenced Code Block

```text
plain text fence
line two
```

### 8.2 JavaScript

```javascript
const heading = '# Hello Markdown'
const tocLink = '[Jump](#hello-markdown)'

function renderPreview(source) {
  return source.trim()
}
```

### 8.3 Python

```python
from pathlib import Path

def collect_markdown_files(root: Path) -> list[Path]:
    return sorted(path for path in root.rglob("*.md") if path.is_file())
```

### 8.4 C++23

```cpp
#include <print>
#include <string_view>

int main() {
    std::string_view const c_Syntax = "Markdown";
    std::println("Working with {}", c_Syntax);
}
```

### 8.5 JSON

```json
{
  "name": "features.md",
  "topic": "markdown syntax",
  "sections": 15,
  "extensions": ["tables", "task_lists", "footnotes", "math", "admonitions"]
}
```

### 8.6 YAML

```yaml
document:
  title: Markdown Syntax
  flavor: GFM
  options:
    tables: true
    footnotes: true
    html_preview: selective
```

### 8.7 Bash

```bash
npm run dev
npm run unit
npx playwright test
```

### 8.8 Indented Code Block

    This is an indented code block.
    It is created by leading indentation.

### 8.9 Nested Fence Example

````markdown
```markdown
# Fence inside fence
```
````

### 8.10 Tilde Fences

```markdown
Using tildes avoids conflict when backticks already appear in the example.
```

---

## 9. Tables

### 9.1 Basic Table

| Syntax Element | Inline or Block | Standard or Extended |
| -------------- | --------------- | -------------------- |
| Emphasis       | Inline          | Standard             |
| Heading        | Block           | Standard             |
| Table          | Block           | Extended             |
| Task list      | Block           | Extended             |

### 9.2 Alignment

| Left Align | Center Align | Right Align |
|:---------- |:------------:| -----------:|
| left       | center       | right       |
| alpha      | beta         | gamma       |

### 9.3 Complex Table

| Feature    | Source Form      | Rendered Meaning     | Notes                       |
| ---------- | ---------------- | -------------------- | --------------------------- |
| Link       | `[text](url)`    | hyperlink            | can be internal or external |
| Image      | `![alt](src)`    | embedded image       | alt text matters            |
| Code fence | triple backticks | preserved code block | supports info strings       |
| Footnote   | `[^id]`          | note reference       | extension                   |
| Admonition | `> [!NOTE]`      | styled callout       | extension                   |

### 9.4 Escaping Pipes in Tables

| Source          | Meaning                        |
| --------------- | ------------------------------ |
| `A \| B`        | escaped pipe in table cell     |
| `` `x           | y` ``                          |
| `$P(A \mid B)$` | conditional probability symbol |

### 9.5 Check Matrix

| Check                 | Status |
| --------------------- |:------:|
| Headings render       | ✅      |
| Tables align          | ✅      |
| Task lists parse      | ✅      |
| HTML table preview    | ✅      |
| Every renderer agrees | ❌      |

### 9.6 Markdown inside tables

- Use <kbd>Shift</kbd>+<kbd>Enter</kbd> within a cell to create new lines. Internally, it uses `<br>` so other markdown viewer still recognize it as a cell.
- Use <kbd>Ctrl</kbd>+<kbd>1</kbd> to cycle the state of task checkboxes.
- Use <kbd>Ctrl</kbd>+<kbd>2</kbd> to cycle the state of bullet points.

| Greek              | Latin |     |
| ------------------ | ----- | --- |
| - [ ] alpha<br>- b |       |     |
| - [x] x            |       |     |
|                    |       |     |

### 9.7 Inline HTML Table

<table>
  <tr>
    <th>Tag</th>
    <th>Role</th>
  </tr>
  <tr>
    <td><table></td>
    <td>table container</td>
  </tr>
  <tr>
    <td><th></td>
    <td>header cell</td>
  </tr>
  <tr>
    <td><td></td>
    <td>data cell</td>
  </tr>
</table>

---

## 10. Math and Technical Notation

### 10.1 Inline Math

Inline math often looks like $x^2 + y^2 = z^2$.

### 10.2 Display Math

$$
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
$$

### 10.3 Matrix Example

$$
A =
\begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{bmatrix}
$$

### 10.4 Aligned Equations

$$
\begin{aligned}
f(x) &= x^2 + 1 \\
f'(x) &= 2x
\end{aligned}
$$

### 10.5 Piecewise Function

$$
f(x) =
\begin{cases}
-1, & x < 0 \\
0, & x = 0 \\
1, & x > 0
\end{cases}
$$

### 10.6 Logic and Set Symbols

- $\forall x \in \mathbb{R}$
- $\exists y \in \mathbb{N}$
- $A \subseteq B$
- $p \Rightarrow q$

---

## 11. Diagrams

### 11.1 Mermaid Flowchart

```mermaid
flowchart TD
    A[Plain text source] --> B[Markdown parser]
    B --> C[AST / token stream]
    C --> D[Renderer]
    D --> E[Preview or export]
```

### 11.2 Mermaid Sequence Diagram

```mermaid
sequenceDiagram
    participant Author
    participant Editor
    participant Parser
    participant Renderer

    Author->>Editor: Write markdown
    Editor->>Parser: Parse content
    Parser-->>Renderer: Structured tokens
    Renderer-->>Author: Visible preview
```

### 11.3 Mermaid State Diagram

```mermaid
stateDiagram-v2
    [*] --> Draft
    Draft --> Reviewed
    Reviewed --> Published
    Published --> Archived
```

### 11.4 Mermaid Gantt Chart

```mermaid
gantt
    title Markdown Documentation Workflow
    dateFormat  YYYY-MM-DD
    section Drafting
    Write outline          :a1, 2026-06-10, 1d
    Fill examples          :a2, after a1, 2d
    section Review
    Technical review       :b1, after a2, 1d
    Update examples        :b2, after b1, 1d
```

### 11.5 Mermaid Class Diagram

```mermaid
classDiagram
    class Document {
        +frontMatter
        +sections
        +links
    }

    class Renderer {
        +renderHtml()
        +renderPreview()
    }

    Document --> Renderer
```

---

## 12. Advanced Markdown

### 12.1 Footnotes

Footnotes are useful for side remarks and citations.[^commonmark-note]

[^commonmark-note]: Footnotes are not part of original Markdown, but are common in extended flavors.

### 12.2 Abbreviations

*[AST]: Abstract Syntax Tree
*[GFM]: GitHub Flavored Markdown
*[TOC]: Table of Contents

An AST is often produced before rendering, and a TOC can be derived from headings.

### 12.3 Collapsible Sections

<details>
<summary>Click to expand a collapsible block</summary>

This is useful for optional detail, logs, notes, or spoiler-like hidden content.

- It can contain lists.
- It can contain code.
- It can contain paragraphs.

</details>

### 12.4 HTML Comments

### 12.5 Mixed HTML and Markdown

<p align="center">
  <strong>Centered HTML block</strong> inside a Markdown document.
</p>

### 12.6 Citation-Style Text

Some scholarly workflows use citation syntax such as [@doe2024markdown] or
multiple references like [@doe2024markdown; @smith2025gfm].

### 12.7 Checklist Table

| Capability             | Available | Notes                      |
| ---------------------- |:---------:| -------------------------- |
| Standard Markdown      | ✅         | core syntax                |
| Tables                 | ✅         | GFM-style                  |
| Task lists             | ✅         | GFM-style                  |
| Footnotes              | ✅         | extension                  |
| Inline HTML            | ✅         | selective behavior varies  |
| Every extension stable | ⚠️        | depends on renderer/editor |

### 12.8 Admonition Summary

> [!SUMMARY]
> Markdown often becomes most useful when plain readability, predictable parsing,
> and minimal syntax noise all remain in balance.

---

## 13. HTML Inside Markdown

### 13.1 Inline HTML

This sentence includes a <span style="color: var(--themeColor)">styled span</span>.

### 13.2 Block HTML

<div>
  <p>HTML blocks may or may not render depending on the application's rules.</p>
</div>

### 13.3 Ruby Annotation

<ruby>Markdown<rt>markup</rt></ruby>

### 13.4 Description List in Raw HTML

<dl>
  <dt>Markdown</dt>
  <dd>Plain-text markup.</dd>
  <dt>Renderer</dt>
  <dd>Turns source into output.</dd>
</dl>

### 13.5 HTML and Markdown Boundary Example

<blockquote>
  <p>This blockquote is raw HTML rather than Markdown blockquote syntax.</p>
</blockquote>

---

## 14. CommonMark and GFM Edge Cases

### 14.1 Lazy Continuation in Blockquotes

> A blockquote can continue
> without `>` on every visual line in some parsing situations.

### 14.2 Tight vs Loose Lists

- tight item one

- tight item two

- loose item one

- loose item two

### 14.3 Ordered List Starting Number

42. This list starts at 42 in source.
43. The next item follows.

### 14.4 Backticks Inside Inline Code

Use double backticks when the code itself contains a backtick: `` `code` ``.

### 14.5 Emphasis Ambiguity

Examples that parsers treat carefully:

- `foo_bar_baz`
- `*a **b** c*`
- `**a *b* c**`

### 14.6 HTML Entity Examples

- &amp;
- &lt;
- &gt;
- &copy;

### 14.7 Link Reference Definitions Far Away From Use

This paragraph references [a deferred definition][deferred-link].

[deferred-link]: https://example.com/deferred

### 14.8 Unordered Marker Mixing

- first style
* second style
+ third style

### 14.9 Fenced Code Directly After List

1. Step one

2. Example code:

   ```json
   {
     "ok": true
   }
   ```

### 14.10 Raw Angle Brackets

Literal text with angle brackets may need escaping: `&lt;tag&gt;`.

### 14.11 Bare Underscore Examples

Identifiers like `snake_case_name` should usually not become emphasis.

### 14.12 Inline HTML Table Mention

The string `<table>` in a paragraph is not the same thing as a real HTML table block.

---

## 15. Reference Material

1. Gruber, J. *Markdown*.
2. CommonMark Specification.
3. GitHub Flavored Markdown Spec.
4. Markdown Guide.
5. GitHub Docs on writing and formatting Markdown.

---

## Appendix A: Stress Tests

### A.1 Long Equation

$$
f(x) =
\int_{0}^{\infty}
\frac{x^n e^{-x/\theta}}{\Gamma(n)\theta^n}
\left(
\sum_{k=0}^{m}
\binom{m}{k}
\alpha^k
\right)
\, dx
$$

### A.2 Unicode Symbols

Common symbols that often appear in Markdown-heavy technical documents:

- Greek: α, β, γ, δ, ε, λ, μ, π, σ, φ, ω
- Operators: ∑, ∏, ∫, ∂, ∇, ≈, ≠, ≤, ≥
- Sets: ℕ, ℤ, ℚ, ℝ, ℂ
- Arrows: ←, ↑, →, ↓, ↔, ⇒, ⇔

### A.3 Badge Table

| Badge                                                         | Meaning                       |
| ------------------------------------------------------------- | ----------------------------- |
| ![Status](https://img.shields.io/badge/status-reference-blue) | This is a reference document  |
| ![Flavor](https://img.shields.io/badge/flavor-gfm-green)      | Targets GFM-compatible syntax |
| ![Math](https://img.shields.io/badge/math-enabled-purple)     | Includes display math         |
| ![HTML](https://img.shields.io/badge/html-selective-orange)   | Includes inline/raw HTML      |

### A.4 Mixed Nested Blocks

> [!IMPORTANT]
> Nested structures inside a callout can stress a renderer:
> 
> 1. ordered item
> 2. second item
>    - nested bullet
>    - nested bullet with `code`
> 
> ```text
> fenced block inside callout
> ```

### A.5 Source-Focused Summary

> [!SUMMARY]
> This document covers headings, paragraphs, emphasis, links, images, lists,
> task lists, definition lists, blockquotes, admonitions, code fences, tables,
> math, diagrams, footnotes, abbreviations, comments, raw HTML, autolinks,
> reference links, escapes, nested fences, Unicode, and several parser edge cases.
