markdown to pdf
Project description
Markdown to PDF Converter
This project provides a CLI and a web-based API service for converting Markdown files into PDF and optionally HTML files.
Features
- Convert Markdown files to PDF with syntax highlighting.
- Optionally generate an HTML version of the output.
- Custom CSS support for styling.
- Adjustable page size and margins.
- List available code highlighting styles.
- FastAPI-based web service with RESTful API.
Installation
To install the required dependencies, use:
pip install -r requirements.txt
CLI Usage
python convert.py [INPUT_FILE] [OUTPUT_FILE] [OPTIONS]
Arguments:
INPUT_FILE(optional): Path to the Markdown file.OUTPUT_FILE(optional): Output PDF file path.
Options:
--style, -s(default:xcode): Code highlighting style.--css, -c: Path to a custom CSS file.--page-size(default:A4): Page size options (e.g.,Letter,A3).--margin(default:0.05in): Page margin settings.--html, -h: Also generate an HTML file.--list-styles, -l: List all available code highlighting styles.
Example:
python convert.py sample.md sample.pdf --html --style=monokai
API Usage
You can run the FastAPI web service to provide Markdown-to-PDF conversion:
python serve.py --host 127.0.0.1 --port 8882
API Endpoints
Convert Markdown to PDF
POST /api/topdf
Parameters:
mdcontent: Markdown content as a form parameter.
Response:
- Returns the generated PDF file.
Health Check
GET /health
Response:
{"status": "ok"}
Running the Server
To start the web server:
python serve.py
By default, the server runs on http://127.0.0.1:8882/.
Dependencies
Clickfor the CLI interface.FastAPIandUvicornfor the web service.MarkdownConverterfor conversion logic.
License
This project is licensed under the MIT License.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xpdf-0.0.2.tar.gz.
File metadata
- Download URL: xpdf-0.0.2.tar.gz
- Upload date:
- Size: 786.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9ed4ff2108dff4333f03541a271f365f18e9f079eaa6668a728549899a2ddb2
|
|
| MD5 |
b587e21132f97354946dcb060b07e131
|
|
| BLAKE2b-256 |
26a497eb9398463dbdbeb5617e018e9d5490ed40a8e030f6b5d94fd58e519288
|
Provenance
The following attestation bundles were made for xpdf-0.0.2.tar.gz:
Publisher:
python-publish.yml on hyxf/xpdf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xpdf-0.0.2.tar.gz -
Subject digest:
c9ed4ff2108dff4333f03541a271f365f18e9f079eaa6668a728549899a2ddb2 - Sigstore transparency entry: 191920962
- Sigstore integration time:
-
Permalink:
hyxf/xpdf@5f6dbdfb9276ba0859e55b607b6840595547acd0 -
Branch / Tag:
refs/tags/0.0.2 - Owner: https://github.com/hyxf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5f6dbdfb9276ba0859e55b607b6840595547acd0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file xpdf-0.0.2-py3-none-any.whl.
File metadata
- Download URL: xpdf-0.0.2-py3-none-any.whl
- Upload date:
- Size: 785.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4211068bb25f1e5649ae4e181813a90f53ca8c635aa1d0fc26cf2b8b7ea60800
|
|
| MD5 |
099b02edc33e5f937e45a42feeec9ec3
|
|
| BLAKE2b-256 |
1fe0134fbea10fa10db48b6212101ab3cd209c67a3643547abdf26aa584ffe50
|
Provenance
The following attestation bundles were made for xpdf-0.0.2-py3-none-any.whl:
Publisher:
python-publish.yml on hyxf/xpdf
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xpdf-0.0.2-py3-none-any.whl -
Subject digest:
4211068bb25f1e5649ae4e181813a90f53ca8c635aa1d0fc26cf2b8b7ea60800 - Sigstore transparency entry: 191920966
- Sigstore integration time:
-
Permalink:
hyxf/xpdf@5f6dbdfb9276ba0859e55b607b6840595547acd0 -
Branch / Tag:
refs/tags/0.0.2 - Owner: https://github.com/hyxf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@5f6dbdfb9276ba0859e55b607b6840595547acd0 -
Trigger Event:
release
-
Statement type: