Markdown Guide - Syntax and Formatting Explained

Comprehensive guide to Markdown syntax, covering headers, lists, code blocks, links, images, tables, and formatting. Learn to write in Markdown effectively.

Markdown Syntax Guide

Markdown Headers

Markdown supports six levels of headers, indicated by the number of hash symbols (#) at the beginning of the line. Ensure there are no quotation marks around the header text.

# h1 header
## h2 header
### h3 header
#### h4 header
##### h5 header
###### h6 header

Markdown Blockquotes

Blockquotes are used to cite text from another source. They are indicated by a greater-than symbol (>) at the beginning of the line.

> This is a blockquote.
>> This is a nested blockquote.
>
> This is another paragraph within the same blockquote.

Collapsible Text

To create a collapsible section, use the HTML <details> and <summary> tags.

<details>
    <summary>Click to expand/collapse</summary>
    <p>This content is hidden by default and appears when the summary is clicked.</p>
    <p>More hidden content here.</p>
</details>

Markdown Lists

Markdown supports both unordered (bulleted) and ordered (numbered) lists. Sub-bullets can be achieved with indentation.

Unordered Lists

Use asterisks (*), plus signs (+), or hyphens (-) for unordered lists.

* Item 1
  * Sub-item 1.1
    * Sub-sub-item 1.1.1
* Item 2
  - Sub-item 2.1
  + Sub-item 2.2
* Item 3

Ordered Lists

Use numbers followed by periods for ordered lists. Indentation can be used for sub-lists.

1. First item
  1. First sub-item
2. Second item
  * Unordered sub-item
3. Third item
  a. Lettered sub-item (mixed support)
4. Fourth item
  i. Roman numeral sub-item (mixed support)

Checklists

Limited support exists for rendering checklists within Markdown.

- [ ] Incomplete task
    - [ ] Incomplete sub-task
    - [x] Complete sub-task
- [x] Complete task

Markdown Code

Inline Code

Use single backticks (`) to format inline code snippets.

Use the `printf()` function for output.

Code Blocks

Code blocks can be created by indenting lines with four spaces or one tab, or by using triple backticks (```) with an optional language specifier for syntax highlighting.

Regular text
    This is an indented code block.

```shell
# Code block with syntax highlighting
alias ltr='ls -ltr'
alias latr='ls -latr'
```

Key Bindings

Use the <kbd> tag for key bindings.

<kbd>⌘F</kbd>

Horizontal Rules

Horizontal rules (***, ---, or ___) can be created using three or more hyphens, asterisks, or underscores on a line by themselves.

***
---
___

Markdown Links

Links are created using square brackets for the visible text and parentheses for the URL. An optional title can be added within the parentheses.

This is [an example](http://example.com "Optional Title") inline link.

Links to Headings

You can link to specific headings within the same document. The link target is typically the case-insensitive heading text with spaces replaced by hyphens.

[Link to Section](#section-id "Hover Text")

Markdown Images

Images are similar to links but start with an exclamation mark (!).

![Alt Text](/path/to/image.png)

Markdown Formatting

Markdown supports basic text formatting.

  • Italic: *em* or _em_
  • Bold: **strong** or __strong__
  • Strikethrough: ~~strikethrough~~

Markdown Tables

Tables can be created using pipes (|) and hyphens (-). Alignment can be controlled using colons.

Table Alignment

The alignment applies to the table data, not the header.

Left-aligned Stuff | Right-aligned Stuff | Center-aligned Stuff
| :--- | ---: | :---:
Some left stuff   | Some right stuff  | Some center stuff
Some left stuff   | Some right stuff  | Some center stuff

Special Characters in Tables

Special characters like pipes can be escaped with a backslash (\).

First Header  | Second Header
------------- | -------------
Some stuff   | things about stuff
Other Stuff  |  A \| B

External Resources