Skip to main content

Convert Markdown files to PDF from your command line.

Project description

markdown-convert

Convert Markdown files to PDF from your command line.

pip install markdown-convert


Button Hover Button Hover




Why 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:

    Feature Example
    LaTeX Math Equations $E=mc^2$ is rendered as a math equation.
    Mermaid, Vega-Lite and Schemdraw Diagrams ```mermaid ... is rendered as a diagram.
    Syntax-Highlighted Code Blocks ```python ... gets syntax highlighting.
    Admonitions !!! note ... is styled as a note box.
    Dynamic Table of Contents [TOC] inserts a Table of Contents.
    Image Attributes ![::shadow::](sky.png) shows a shadow behind the image.
    Captions ![sky](sky.png)_A beautiful sky_ shows a caption, centered below the image.
    Tables and Queries > [my_table] under your table gives it a name,
    [query:select ... from my_table] queries it.
    Live Conversion markdown-convert file.md --mode=live updates the PDF every time the Markdown file changes.
    Custom CSS markdown-convert file.md --css=style.css extends the default CSS with your own stylesheet.
    Task Lists, Containers, CSS Paged Media and more! ...

    Check out CUSTOM_SYNTAX.md for all the extra features and how to use them.

Installation

markdown-convert is available on PyPI and can be installed via pip:

pip install markdown-convert

Usage

1. From your terminal

Simply run markdown-convert file.md to convert file.md to file.pdf.

You can specify the following options:

Usage:
  markdown-convert [markdown_file_path] [options]

Options:
  --mode=once|live|debug
      Convert the markdown file once (default) or live.
      Use debug to preserve the intermediate html file.
  --css=[css_file_path]
      Use a custom CSS file.
  --out=[output_file_path]
      Specify the output file path.
  --extras=[extra1,extra2,...]
      Specify the extras to use. Uses all extras if not specified.
      Supported extras:
        admonitions,anchors,task-lists,math,custom-spans,highlights,
        syntax-highlighting,table-of-contents,vega-lite,inline-math,
        block-math,schemdraw,mermaid,dynamic-tables,dynamic-queries
  --security=default|strict
      Specify the security level.
      Strict mode disables inline HTML, internet access and JS,
      but local files can still be referenced.
      This improves security, but will break some extras.

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.

2. As a Python library

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')

3. From the context menu of your file explorer

Install the extension of your choice:

Then right click any Markdown file and select Convert to PDF to convert it.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

markdown_convert-2.0.8.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

markdown_convert-2.0.8-py3-none-any.whl (29.6 kB view details)

Uploaded Python 3

File details

Details for the file markdown_convert-2.0.8.tar.gz.

File metadata

  • Download URL: markdown_convert-2.0.8.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for markdown_convert-2.0.8.tar.gz
Algorithm Hash digest
SHA256 74508b9a8209cab4ce5adcf46c75b12cd8b9f310632e73ccda26da973ce7fecf
MD5 584d5b0ffe3e6ae410fa8613c5345cc1
BLAKE2b-256 c91ad8d9056addf45de9681d9b93e32bef32a1602807bdf7ea25000874ae1948

See more details on using hashes here.

File details

Details for the file markdown_convert-2.0.8-py3-none-any.whl.

File metadata

  • Download URL: markdown_convert-2.0.8-py3-none-any.whl
  • Upload date:
  • Size: 29.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for markdown_convert-2.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 f06b86c308fa1da6892af44afce410ac5ef7215b44c344bb14e7e922376da587
MD5 e3e7ef12d4b2b7d6df7280b4fa291850
BLAKE2b-256 4f2cf379315c17e728eaa187ce9c7d3484e17eea6b9162e0e5ec18d3c918ad4e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page