Skip to content

Markdown

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

3 modules

ModuleDescription
Parse FrontmatterExtract YAML frontmatter from Markdown content
Markdown to HTMLConvert Markdown text to HTML
Generate Table of ContentsGenerate a table of contents from Markdown headings

Modules

Parse Frontmatter

markdown.parse_frontmatter

Extract YAML frontmatter from Markdown content

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-Markdown content with frontmatter

Output:

FieldTypeDescription
frontmatterobjectParsed frontmatter as a dictionary
contentstringMarkdown content without frontmatter

Example: Parse YAML frontmatter

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

# Hello World

Content here.

Markdown to HTML

markdown.to_html

Convert Markdown text to HTML

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-Markdown content to convert
extensionsarrayNo-Markdown extensions to enable (only used with the markdown library)

Output:

FieldTypeDescription
htmlstringConverted HTML content
word_countnumberWord count of the input text

Example: Convert markdown to HTML

yaml
text: # Hello

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

Generate Table of Contents

markdown.toc

Generate a table of contents from Markdown headings

Parameters:

NameTypeRequiredDefaultDescription
textstringYes-Markdown content to extract headings from
max_depthnumberNo3Maximum heading depth to include (1-6)

Output:

FieldTypeDescription
tocarrayList of headings with level, title, and slug
toc_markdownstringFormatted Markdown table of contents

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.