Quickstart

Parse your first Markdown document in 2 minutes

1 min read 184 words

Parse Markdown to a typed AST and render to HTML in 2 minutes.

Step 1: Parse Markdown

from patitas import parse

source = """
# Welcome

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

- Item one
- Item two
"""

doc = parse(source)

Step 2: Explore the AST

# doc is a tuple of Block nodes
print(len(doc))  # 3 (Heading, Paragraph, List)

# Access the heading
heading = doc[0]
print(heading.level)  # 1
print(heading.children)  # [Text("Welcome")]

# Access the paragraph
para = doc[1]
print(para.children)  # [Text, Strong, Text, Emphasis, Text]

Step 3: Render to HTML

from patitas import render

html = render(doc, source=source)
print(html)

Output:

<h1>Welcome</h1>
<p>This is <strong>bold</strong> and <em>italic</em> text.</p>
<ul>
<li>Item one</li>
<li>Item two</li>
</ul>

Step 4: All-in-One

For simple use cases, use theMarkdownclass:

from patitas import Markdown

md = Markdown()
html = md("# Hello **World**")
print(html)
# <h1>Hello <strong>World</strong></h1>

Next Steps

  • [Syntax Guide] — Learn all Markdown syntax
  • API Reference — Full API documentation
  • Architecture — How the parser works