คู่มือไวยากรณ์ Markdown
ไวยากรณ์สำคัญสำหรับจัดรูปแบบเอกสาร
ภาพรวม
Markdown เป็น markup language เบาที่ใช้เพิ่มองค์ประกอบการจัดรูปแบบในเอกสารข้อความธรรมดา John Gruber สร้างเมื่อปี 2004 ปัจจุบันเป็นหนึ่งใน markup language ที่นิยมที่สุดในโลก
การใช้ Markdown ต่างจาก WYSIWYG อย่าง Word ที่คุณกดปุ่มจัดรูปแบบแล้วเห็นทันที ใน Markdown คุณใส่ไวยากรณ์ลงข้อความเพื่อบอกว่าคำหรือวลีไหนจะแสดงต่างออกไป
หัวข้อ
ใส่ # ข้างหน้าคำหรือวลี จำนวน # เทียบกับระดับหัวข้อ เช่น ### หัวข้อของฉัน = ระดับ 3
Heading level 1
Heading level 2
Heading level 3
Heading level 4
Heading level 5
Heading level 6
ย่อหน้า
สร้างย่อหน้าโดยเว้นบรรทัดว่างคั่นระหว่างบรรทัดข้อความ
It lets me write easily.
<p>It lets me write easily.</p>
I really like using Markdown.
It lets me write easily.
ขึ้นบรรทัดใหม่
จบบรรทัดด้วยช่องว่างสองตัวขึ้นไป แล้วกด Enter
And this is the second line.
And this is the second line.</p>
This is the first line.
And this is the second line.
เน้นข้อความ
เน้นได้ด้วยตัวหนาหรือตัวเอียง
ตัวหนา
ใส่ ** หรือ __ ก่อนและหลังคำหรือวลี
I just love bold text.
I just love bold text.
ตัวเอียง
ใส่ * หรือ _ ก่อนและหลังคำหรือวลี
The cat meows.
The cat meows.
ตัวหนาและเอียง
ใส่ *** หรือ ___ ก่อนและหลังคำหรือวลี
This text is really important.
This text is really important.
อ้างอิง
ใส่ > ข้างหน้าย่อหน้า
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.
รายการ
จัดเป็นรายการมีเลขหรือไม่มีเลขได้
รายการมีเลข
ใส่เลขตามด้วยจุดข้างหน้า แต่ละบรรทัด เลขไม่ต้องเรียง แต่ควรเริ่มที่ 1
2. Second item
3. Third item
4. Fourth item
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
<li>Fourth item</li>
</ol>
- First item
- Second item
- Third item
- Fourth item
รายการไม่มีเลข
ใส่ - หรือ * หรือ + ข้างหน้าบรรทัด
- Second item
- Third item
- Fourth item
<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
โค้ด
ใส่คำหรือวลีใน backtick `
At the command prompt, type nano.
บล็อกโค้ด
เยื้องอย่างน้อย 4 ช่องหรือ 1 tab ทุกบรรทัด หรือใช้ ``` ก่อนและหลังบล็อก
{
"firstName": "John",
"lastName": "Smith",
"age": 25
}
```
{
"firstName": "John",
"lastName": "Smith",
"age": 25
}เส้นแนวนอน
ใช้ *** หรือ --- หรือ ___ คนเดียวทั้งบรรทัด
ลิงก์
ใส่ข้อความลิงก์ใน [ ] ตามด้วย URL ใน ( ) เช่น [Duck Duck Go](https://duckduckgo.com)
My favorite search engine is Duck Duck Go.
เพิ่มชื่อลิงก์
ใส่ชื่อลิงก์ (tooltip เมื่อเอาเมาส์ชี้) ในเครื่องหมายคำพูดหลัง URL ได้
My favorite search engine is Duck Duck Go.
รูปภาพ
ใส่ ! ตามด้วย [alt] แล้ว (url รูป) จะเพิ่มชื่อใน " " หลัง URL ก็ได้

การ escape อักขระ
ใส่ \ ข้างหน้าอักขระที่จะใช้จัดรูปแบบ ถ้าต้องการให้แสดงตรงตัว
* Without the backslash, this would be a bullet in an unordered list.
อักขระที่ escape ได้
ใช้ backslash escape อักขระเหล่านี้:
| \ | backslash |
| ` | backtick |
| * | asterisk |
| _ | underscore |
| { } | curly braces |
| [ ] | brackets |
| ( ) | parentheses |
| # | pound sign |
| + | plus sign |
| - | minus sign (hyphen) |
| . | dot |
| ! | exclamation mark |
| | | pipe |
ตาราง
ใช้ --- สร้างหัวคอลัมน์ และ | คั่นคอลัมน์ จะใส่ | ขอบตารางก็ได้
| --------- | ----------- |
| Header | Title |
| Paragraph | Text |
| Syntax | Description |
|---|---|
| Header | Title |
| Paragraph | Text |
การจัดแนว
ใส่ : ทางซ้าย ขวา หรือทั้งสองข้างของ --- ในแถวหัวเพื่อจัดแนวคอลัมน์
| :--- | :---: | ---: |
| This | This | This |
| column | column | column |
| will | will | will |
| align | align | align |
| left | center | right |
| ชิดซ้าย | กึ่งกลาง | ชิดขวา |
|---|---|---|
| This | This | This |
| column | column | column |
| will | will | will |
| align | align | align |
| left | center | right |