Convert Markdown files to PDF from your command line.
pip install markdown-convert
Unlike other similar tools, markdown-convert:
- Can be fully installed via
pip install markdown-convert, with no external system-level dependencies. - Comes with a sensible default CSS stylesheet out of the box.
- Supports:
- LaTeX math equations:
$...$for inline and$$...$$for block equations. - Mermaid diagrams:
```mermaid ...```code blocks get rendered as diagrams. - Syntax highlighting for code blocks: Applied automatically based on the specified language.
- Live conversion:
markdown-convert file.md --mode=liveupdates the PDF every time the Markdown file changes. - Custom CSS
markdown-convert file.md --css=style.cssextends the default CSS with your own stylesheet. - Pipe tables, checkboxes, header links, CSS paged media features and more!
- LaTeX math equations:
markdown-convert is available on PyPI and can be installed via pip:
pip install markdown-convertSimply run markdown-convert file.md to convert file.md to file.pdf.
You can specify the following options:
--mode=once|live: Convert the markdown file once (default) or live.--css=[css_file_path]: Use a custom CSS file.--out=[output_file_path]: Specify the output file path.
For example: markdown-convert README.md --mode=live --css=style.css --out=output.pdf will convert README.md to output.pdf using style.css and update the PDF live as you edit the Markdown file.
You can also use markdown-convert as a library in your Python code:
from markdown_convert import convert, convert_text, live_convert
# Convert your Markdown file and save it as a PDF file
convert('README.md', 'style.css', 'README.pdf')
# Convert your Markdown string and get the PDF bytes
pdf_bytes = convert_text('# Hello World', 'h1 { color: red; }')
# Convert your Markdown file to PDF every time it changes
live_convert('README.md', 'style.css', 'README.pdf')Install the extension of your choice:
- For Windows Explorer: markdown_convert_explorer
- For Linux (Nautilus): markdown_convert_nautilus
Then right click any Markdown file and select Convert to PDF to convert it.
