Install & Compatibility
Where this runs
tested against v2.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.047s · 18MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 1.5s · import 0.043s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Document
✓ from snakemd import Document
Paragraph
✓ from snakemd import Paragraph
✗ from snakemd.elements import Paragraph
Most elements are now directly importable from the top-level package.
Heading
✓ from snakemd import Heading
Table
✓ from snakemd import Table
This quickstart demonstrates how to create a basic Markdown document with headings, paragraphs, lists, and tables, and then render it to a file using SnakeMD. It covers the core `Document` object and common content addition methods.
import snakemd
# Create a new Document
doc = snakemd.Document("My Article")
# Add a heading
doc.add_heading("Welcome to SnakeMD!")
# Add a paragraph
doc.add_paragraph("This is an example of how to use SnakeMD to generate Markdown.")
# Add an ordered list
doc.add_ordered_list(["First item", "Second item", "Third item"])
# Add a table
doc.add_table(
headers=["Name", "Age"],
data=[["Alice", "30"], ["Bob", "24"]]
)
# Output the Markdown to a file
# In a real scenario, you might want to save to a specific path
# and handle potential file I/O errors.
output_filename = os.environ.get('SNAKEMD_OUTPUT_FILE', 'output.md')
with open(output_filename, "w") as f:
f.write(doc.render())
print(f"Markdown written to {output_filename}")
Debug
Known issues
breakingVersion 2.0.0 of SnakeMD removed all previously deprecated classes, parameters, and methods. Code written for 1.x.x versions (e.g., using `add_element` or older class names) will likely result in `AttributeError` or `TypeError`.fixReview the migration guide for SnakeMD 2.0.0 and update your code to use the new API, including specific `add_` methods on the `Document` object (e.g., `add_heading`, `add_paragraph`, `add_table`).
affects: <2.0.0 migrating to >=2.0.0
gotchaPrior to v2.4.0, a bug existed where inline styles (like bold or italics) inside linked text would be stripped, leading to plain text links. This affects markdown rendering where complex inline styling within links is desired.fixUpgrade to SnakeMD version 2.4.0 or newer to ensure inline styles within links are preserved correctly. `pip install --upgrade snakemd`.
affects: <2.4.0
gotchaIn versions prior to 2.4.0, the processing of inline elements within `BlockQuote` (and potentially other elements) could lead to issues where embedded formatting was not correctly respected, resulting in improperly rendered Markdown.fixUpgrade to SnakeMD version 2.4.0 or newer to fix issues related to inline element processing in quotes and other complex structures. `pip install --upgrade snakemd`.
affects: <2.4.0
Errors
Common errors & fixes
AttributeError: 'Document' object has no attribute 'add_element'
Attempting to use a method (`add_element`) that was removed in SnakeMD 2.0.0. This was a common way to add content in 1.x.x versions.
fixReplace calls to `doc.add_element(...)` with specific methods like `doc.add_heading(...)`, `doc.add_paragraph(...)`, `doc.add_table(...)`, etc. Refer to the SnakeMD 2.0.0 documentation for the updated API.
ModuleNotFoundError: No module named 'snakemd.elements'
Attempting to import elements (e.g., `Paragraph`, `Heading`) directly from an internal or deprecated module path. In current versions, most public elements are exposed directly under the `snakemd` package.
fixChange your import statements from `from snakemd.elements import ...` to `from snakemd import ...` (e.g., `from snakemd import Paragraph, Heading`).
Markdown output does not show bold text inside a link, it's just plain text.
This is a known bug in SnakeMD versions prior to 2.4.0, where the linking mechanism would inadvertently strip inline styles from its content.
fixUpgrade your SnakeMD installation to version 2.4.0 or newer: `pip install --upgrade snakemd`.
Upgrade
Version history
2.4.1latest on PyPI · released May 30, 2026
Audit
Dependencies
No dependency data recorded yet.