Skip to content

Markdown

Parse frontmatter, convert to HTML, and generate table of contents.

3 modules

ModuleDescription
แยกวิเคราะห์ Frontmatterดึง YAML frontmatter จากเนื้อหา Markdown
Markdown เป็น HTMLแปลงข้อความ Markdown เป็น HTML
สร้างสารบัญสร้างสารบัญจากหัวข้อใน Markdown

Modules

แยกวิเคราะห์ Frontmatter

markdown.parse_frontmatter

ดึง YAML frontmatter จากเนื้อหา Markdown

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-เนื้อหา Markdown ที่มี frontmatter

Output:

FieldTypeDescription
frontmatterobjectfrontmatter ที่แยกวิเคราะห์แล้วในรูปแบบพจนานุกรม
contentstringเนื้อหา Markdown ที่ไม่มี frontmatter

Example: Parse YAML frontmatter

yaml
text: ---
title: Hello World
date: 2024-01-01
tags:
  - python
  - markdown
---

# Hello World

Content here.

Markdown เป็น HTML

markdown.to_html

แปลงข้อความ Markdown เป็น HTML

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-เนื้อหา Markdown ที่จะแปลง
extensionsarrayNo-ส่วนขยาย Markdown ที่จะเปิดใช้งาน (ใช้กับไลบรารี markdown เท่านั้น)

Output:

FieldTypeDescription
htmlstringเนื้อหา HTML ที่แปลงแล้ว
word_countnumberจำนวนคำของข้อความที่ป้อน

Example: Convert markdown to HTML

yaml
text: # Hello

This is **bold** and *italic*.

สร้างสารบัญ

markdown.toc

สร้างสารบัญจากหัวข้อใน Markdown

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-เนื้อหา Markdown ที่จะดึงหัวข้อออกมา
max_depthnumberNo3ความลึกของหัวข้อสูงสุดที่รวม (1-6)

Output:

FieldTypeDescription
tocarrayรายการหัวข้อพร้อมระดับ ชื่อ และ slug
toc_markdownstringสารบัญในรูปแบบ Markdown

Example: Generate TOC from markdown

yaml
text: # Introduction

## Getting Started

### Installation

### Configuration

## Usage

## API Reference
max_depth: 3

Released under the Apache 2.0 License.