{"id":10236,"library":"snakemd","title":"SnakeMD","description":"SnakeMD is a Python library designed for programmatically generating Markdown documents. It allows users to create headings, paragraphs, lists, tables, and other Markdown elements using a Pythonic API. The library is actively maintained, with version 2.4.0 being the latest stable release, and typically sees updates every few months.","status":"active","version":"2.4.0","language":"en","source_language":"en","source_url":"https://github.com/TheRenegadeCoder/SnakeMD","tags":["markdown","documentation","generator","md"],"install":[{"cmd":"pip install snakemd","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"Document","correct":"from snakemd import Document"},{"note":"Most elements are now directly importable from the top-level package.","wrong":"from snakemd.elements import Paragraph","symbol":"Paragraph","correct":"from snakemd import Paragraph"},{"symbol":"Heading","correct":"from snakemd import Heading"},{"symbol":"Table","correct":"from snakemd import Table"}],"quickstart":{"code":"import snakemd\n\n# Create a new Document\ndoc = snakemd.Document(\"My Article\")\n\n# Add a heading\ndoc.add_heading(\"Welcome to SnakeMD!\")\n\n# Add a paragraph\ndoc.add_paragraph(\"This is an example of how to use SnakeMD to generate Markdown.\")\n\n# Add an ordered list\ndoc.add_ordered_list([\"First item\", \"Second item\", \"Third item\"])\n\n# Add a table\ndoc.add_table(\n    headers=[\"Name\", \"Age\"],\n    data=[[\"Alice\", \"30\"], [\"Bob\", \"24\"]]\n)\n\n# Output the Markdown to a file\n# In a real scenario, you might want to save to a specific path\n# and handle potential file I/O errors.\noutput_filename = os.environ.get('SNAKEMD_OUTPUT_FILE', 'output.md')\nwith open(output_filename, \"w\") as f:\n    f.write(doc.render())\n\nprint(f\"Markdown written to {output_filename}\")","lang":"python","description":"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."},"warnings":[{"fix":"Review 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`).","message":"Version 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`.","severity":"breaking","affected_versions":"<2.0.0 migrating to >=2.0.0"},{"fix":"Upgrade to SnakeMD version 2.4.0 or newer to ensure inline styles within links are preserved correctly. `pip install --upgrade snakemd`.","message":"Prior 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.","severity":"gotcha","affected_versions":"<2.4.0"},{"fix":"Upgrade 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`.","message":"In 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.","severity":"gotcha","affected_versions":"<2.4.0"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Replace 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.","cause":"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.","error":"AttributeError: 'Document' object has no attribute 'add_element'"},{"fix":"Change your import statements from `from snakemd.elements import ...` to `from snakemd import ...` (e.g., `from snakemd import Paragraph, Heading`).","cause":"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.","error":"ModuleNotFoundError: No module named 'snakemd.elements'"},{"fix":"Upgrade your SnakeMD installation to version 2.4.0 or newer: `pip install --upgrade snakemd`.","cause":"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.","error":"Markdown output does not show bold text inside a link, it's just plain text."}]}