Skip to content

Markdown

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

3 modules

ModuleDescription
フロントマターを解析MarkdownコンテンツからYAMLフロントマターを抽出
MarkdownをHTMLに変換MarkdownテキストをHTMLに変換
目次を生成Markdownの見出しから目次を生成

Modules

フロントマターを解析

markdown.parse_frontmatter

MarkdownコンテンツからYAMLフロントマターを抽出

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-フロントマター付きのMarkdownコンテンツ

Output:

FieldTypeDescription
frontmatterobject辞書として解析されたフロントマター
contentstringフロントマターなしのMarkdownコンテンツ

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レベル、タイトル、スラッグ付きの見出しリスト
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.