Panduan Sintaks Markdown

Sintaks penting untuk memformat dokumen anda

Gambaran

Markdown ialah bahasa penanda ringan yang boleh anda gunakan untuk menambah elemen pemformatan pada dokumen teks biasa. Dicipta oleh John Gruber pada 2004, Markdown kini salah satu bahasa penanda paling popular di dunia.

Menggunakan Markdown berbeza daripada editor WYSIWYG. Dalam aplikasi seperti Microsoft Word, anda klik butang untuk memformat perkataan dan frasa, dan perubahan kelihatan serta-merta. Markdown tidak begitu. Apabila anda mencipta fail berformat Markdown, anda menambah sintaks Markdown pada teks untuk menunjukkan perkataan dan frasa mana yang patut kelihatan berbeza.

Tajuk

Untuk mencipta tajuk, tambah tanda nombor (#) di hadapan perkataan atau frasa. Bilangan tanda nombor sepadan dengan peringkat tajuk. Contohnya, untuk tajuk peringkat tiga, guna tiga tanda nombor (e.g. ### Tajuk Saya).

Markdown
HTML
Output Diterjemah
# Heading level 1
<h1>Heading level 1</h1>

Heading level 1

## Heading level 2
<h2>Heading level 2</h2>

Heading level 2

### Heading level 3
<h3>Heading level 3</h3>

Heading level 3

#### Heading level 4
<h4>Heading level 4</h4>

Heading level 4

##### Heading level 5
<h5>Heading level 5</h5>
Heading level 5
###### Heading level 6
<h6>Heading level 6</h6>
Heading level 6

Perenggan

Untuk mencipta perenggan, gunakan baris kosong untuk memisahkan satu atau lebih baris teks.

Markdown
HTML
Output Diterjemah
I really like using Markdown.

It lets me write easily.
<p>I really like using Markdown.</p>
<p>It lets me write easily.</p>

I really like using Markdown.

It lets me write easily.

Putus Baris

Untuk mencipta putus baris atau baris baru, akhiri baris dengan dua atau lebih ruang, kemudian tekan return.

Markdown
HTML
Output Diterjemah
This is the first line.
And this is the second line.
<p>This is the first line.<br>
And this is the second line.</p>

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

Penekanan

Anda boleh menambah penekanan dengan menjadikan teks tebal atau condong.

Tebal

Untuk teks tebal, tambah dua asterisk (**) atau garis bawah (__) sebelum dan selepas perkataan atau frasa.

Markdown
HTML
Output Diterjemah
I just love **bold text**.
I just love <strong>bold text</strong>.

I just love bold text.

I just love __bold text__.
I just love <strong>bold text</strong>.

I just love bold text.

Condong

Untuk teks condong, tambah satu asterisk (*) atau garis bawah (_) sebelum dan selepas perkataan atau frasa.

Markdown
HTML
Output Diterjemah
The *cat* meows.
The <em>cat</em> meows.

The cat meows.

The _cat_ meows.
The <em>cat</em> meows.

The cat meows.

Tebal dan Condong

Untuk menekankan teks dengan tebal dan condong serentak, tambah tiga asterisk (***) atau garis bawah (___) sebelum dan selepas perkataan atau frasa.

Markdown
HTML
Output Diterjemah
This text is ***really important***.
This text is <strong><em>really important</em></strong>.

This text is really important.

This text is ___really important___.
This text is <strong><em>really important</em></strong>.

This text is really important.

Blockquote

Untuk mencipta blockquote, tambah > di hadapan perenggan.

Markdown
HTML
Output Diterjemah
> Dorothy followed her through many of the beautiful rooms in her castle.
<blockquote><p>Dorothy followed her through many of the beautiful rooms in her castle.</p></blockquote>

Dorothy followed her through many of the beautiful rooms in her castle.

Blockquote Bersarang

Blockquote boleh disarangkan. Tambah >> di hadapan perenggan yang ingin disarangkan.

Markdown
Output Diterjemah
> Dorothy followed her through many of the beautiful rooms in her castle.
>
>> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.

Dorothy followed her through many of the beautiful rooms in her castle.

The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.

Senarai

Anda boleh menyusun item dalam senarai bernombor dan tidak bernombor.

Senarai Bernombor

Untuk mencipta senarai bernombor, tambah item baris dengan nombor diikuti titik. Nombor tidak perlu mengikut urutan, tetapi senarai patut bermula dengan nombor satu.

Markdown
HTML
Output Diterjemah
1. First item
2. Second item
3. Third item
4. Fourth item
<ol>
  <li>First item</li>
  <li>Second item</li>
  <li>Third item</li>
  <li>Fourth item</li>
</ol>
  1. First item
  2. Second item
  3. Third item
  4. Fourth item

Senarai Tidak Bernombor

Untuk mencipta senarai tidak bernombor, tambah sempang (-), asterisk (*), atau tanda tambah (+) di hadapan item baris.

Markdown
HTML
Output Diterjemah
- First item
- Second item
- Third item
- Fourth item
<ul>
  <li>First item</li>
  <li>Second item</li>
  <li>Third item</li>
  <li>Fourth item</li>
</ul>
  • First item
  • Second item
  • Third item
  • Fourth item

Kod

Untuk menandakan perkataan atau frasa sebagai kod, letakkan dalam backtick (`).

Markdown
HTML
Output Diterjemah
At the command prompt, type `nano`.
At the command prompt, type <code>nano</code>.

At the command prompt, type nano.

Blok Kod

Untuk mencipta blok kod, inden setiap baris blok sekurang-kurangnya empat ruang atau satu tab, atau guna tiga backtick (```) sebelum dan selepas blok kod.

Markdown
Output Diterjemah
```
{
  "firstName": "John",
  "lastName": "Smith",
  "age": 25
}
```
{
  "firstName": "John",
  "lastName": "Smith",
  "age": 25
}

Garis Mendatar

Untuk mencipta garis mendatar, guna tiga atau lebih asterisk (***), sempang (---), atau garis bawah (___) pada baris sendiri.

Markdown
HTML
Output Diterjemah
***
<hr>

---
<hr>

___
<hr>

Imej

Untuk menambah imej, tambah tanda seru (!), diikuti teks alt dalam kurungan, dan laluan atau URL ke aset imej dalam kurungan. Anda boleh pilihan menambah tajuk dalam tanda petik selepas laluan atau URL.

Markdown
HTML
Output Diterjemah
![The San Juan Mountains](https://mdg.imgix.net/assets/images/san-juan-mountains.jpg "San Juan Mountains")
<img src="https://mdg.imgix.net/assets/images/san-juan-mountains.jpg" alt="The San Juan Mountains" title="San Juan Mountains">
The San Juan Mountains

Melarikan Aksara

Untuk memaparkan aksara literal yang sebaliknya digunakan untuk memformat teks dalam dokumen Markdown, tambah backslash (\) di hadapan aksara.

Markdown
Output Diterjemah
\* Without the backslash, this would be a bullet in an unordered list.

* Without the backslash, this would be a bullet in an unordered list.

Aksara Yang Boleh Dilarikan

Anda boleh guna backslash untuk melarikan aksara berikut:

\backslash
`backtick
*asterisk
_underscore
{ }curly braces
[ ]brackets
( )parentheses
#pound sign
+plus sign
-minus sign (hyphen)
.dot
!exclamation mark
|pipe

Jadual

Untuk menambah jadual, guna tiga atau lebih sempang (---) untuk mencipta header setiap lajur, dan guna paip (|) untuk memisahkan setiap lajur. Anda boleh pilihan menambah paip di kedua-dua hujung jadual.

Markdown
Output Diterjemah
| Syntax    | Description |
| --------- | ----------- |
| Header    | Title       |
| Paragraph | Text        |
SyntaxDescription
HeaderTitle
ParagraphText

Penjajaran

Anda boleh menjajarkan teks dalam lajur ke kiri, kanan, atau tengah dengan menambah kolon (:) di kiri, kanan, atau kedua-dua belah sempang dalam baris header.

Markdown
Output Diterjemah
| Align Left | Align Center | Align Right |
| :--- | :---: | ---: |
| This | This | This |
| column | column | column |
| will | will | will |
| align | align | align |
| left | center | right |
Jajar KiriJajar TengahJajar Kanan
ThisThisThis
columncolumncolumn
willwillwill
alignalignalign
leftcenterright