markdown-strings
raw JSON → 3.4.0 verified Fri May 01 auth: no python
A Python library for programmatically generating Markdown formatted text. Current version 3.4.0 (with v4.0.0a1 alpha release featuring a complete API rewrite). Release cadence: irregular.
pip install markdown-strings Common errors
error AttributeError: module 'markdown_strings' has no attribute 'bold' ↓
cause You installed v4 alpha which removed 'bold'.
fix
Downgrade to v3.4.0: pip install markdown-strings==3.4.0
error NameError: name 'md' is not defined ↓
cause Forgot to import or used incorrect import statement.
fix
Add 'import markdown_strings as md' at the top of your script.
error TypeError: header() missing 1 required positional argument: 'level' ↓
cause Called header('text') without specifying level.
fix
Use header('text', 1) with two arguments.
Warnings
breaking v4.0.0a1 is a complete API rewrite. Functions and signatures have changed. Do not upgrade to alpha in production. ↓
fix Stay on 3.x until stable v4 release.
gotcha The function name 'header' takes level as second argument (1-indexed). This differs from some other Markdown libraries. ↓
fix Use md.header('text', 2) for ## heading, not md.header('text', 2).
deprecated Function 'bold' and 'italic' are deprecated in v4 alpha; use 'strong' and 'emphasis' instead. ↓
fix Use md.strong('text') and md.emphasis('text') in v4.
Imports
- md wrong
import markdown_strings as mdscorrectimport markdown_strings as md - header wrong
from markdown_strings import headingcorrectfrom markdown_strings import header
Quickstart
import markdown_strings as md
text = md.header("Hello, World!", 1)
text += md.bold("Important")
print(text)