Python wrapper for converting/reducing AsciiDoc files back to Markdown.
Project description
Pydowndoc
Rapidly convert your AsciiDoc files to Markdown, using Python
A Python wrapper around the latest-built binary of downdoc; a rapid AsciiDoc to Markdown converter.
Why Use Pydowndoc?
- Run downdoc from the CLI within your virtual environment
- Use PyPI as the single installation location of your Python project tooling
- Use the API to convert files using your own Python code/scripts
- Use the Hatch plugin to convert your project’s README.adoc file to Markdown (or any other PyPI supported README format), when building your package
Installation
Run as a uv tool (no installation necessary)
uvx --from Pydowndoc-bin -- downdoc --version
💡 TIP
uv will warn you that thedowndocbinary is not directly provided by thePydowndoc[bin]package, so we suggest to use--from Pydowndoc-binwhen running downdoc usinguvxoruv tool.
Add to your uv project/script’s dependencies
uv add Pydowndoc[bin]
Install permanently as a uv tool
uv tool install Pydowndoc-bin
Install using pip after creating a virtual environment
path/to/venv/python -m pip install Pydowndoc[bin]
Installing the downdoc Binary
Pydowndoc assumes by default that you wish to use the downdoc binary already installed on your system (E.g. using your system’s package manager).
Installing the PyPI package Pydowndoc will only install the Python compatibility layer for downdoc.
If you wish to also install the downdoc binary itself, please install using the [bin] extra.
Installing without the [bin] extra on a system where downdoc is not already installed will not work
$ uvx --with Pydowndoc python -c "import pydowndoc; pydowndoc.get_help()"
OSError: The downdoc executable could not be found. Ensure it is installed (E.g `uv add Pydowndoc[bin]`).
📌 NOTE
Once PEP 771 is finalised, the default install will include the[bin]extra, and using thedowndocbinary already installed on your system will require opting-out from including the[bin]extra.
CLI Usage
These commands will only work correctly after the downdoc binary has been installed, either as a system binary or using the [bin] extra.
See Installing the downdoc Binary for more information.
Display the current version number (useful to validate that installation was successful)
downdoc --version
Display the help message
downdoc --help
Convert a given file (the same filename will be retained, with file-extension changed to .md)
downdoc MyNotes.adoc
Output the converted file to the given filename & path
downdoc MyNotes.adoc -o path/to/output.md
Output the converted file to stdout
downdoc MyNotes.adoc -o -
Read the input AsciiDoc file from stdin
cat MyNotes.adoc | downdoc - -o MyNotes.md
API Usage
Convert a given file. (The same filename will be retained, with file-extension changed to .md)
from pathlib import Path
import pydowndoc
pydowndoc.convert_file(Path("MyNotes.adoc"))
Output the converted file to the given location
from pathlib import Path
import pydowndoc
pydowndoc.convert_file(Path("MyNotes.adoc"), output_location=Path("path/to/output.md"))
Retrieve the converted file as a string
from pathlib import Path
import pydowndoc
converted_file_content: str = pydowndoc.convert_file(
Path("MyNotes.adoc"), output_location=pydowndoc.OUTPUT_CONVERSION_TO_STRING,
)
Convert an in-memory string
from pathlib import Path
import pydowndoc
original_content: str = ...
converted_content: str = pydowndoc.convert_string(original_content)
Use an alternative conversion backend
from pathlib import Path
import pydowndoc
from pydowndoc.conversion_backends import PandocMultiMarkdownConversionBackend
pydowndoc.convert_file(Path("MyNotes.adoc"), backend=PandocMultiMarkdownConversionBackend)
Retrieve the version number of the currently installed downdoc executable
import pydowndoc
version_string: str = pydowndoc.get_version()
💡 TIP
This project includes function docstrings and modern type annotations, allowing you to search for API functionality using your IDE or any program with Python LSP support.
Use as a Hatch build hook
-
Ensure the
readmefield is added to yourproject.dynamiclist within yourpyproject.tomlfile[project] name = "my-cool-project" version = "0.1.0" dynamic = ["readme"]
-
Set up your build backend, within your
pyproject.tomlfile, addingPydowndoc[bin]as a build dependency[build-system] build-backend = "hatchling.build" requires = ["hatchling", "Pydowndoc[bin]"]
💡 TIP
To prevent issues with users building your package that may not have thedowndocbinary already installed on their system, we suggest including the[bin]extra in your package’s build dependencies. -
Include the hook name within
[tool.hatch.metadata.hooks]to enable README-file conversion[tool.hatch.metadata.hooks.downdoc-readme]or
[tool.hatch.metadata.hooks] downdoc-readme = {}
-
Using a path to a custom README file
[tool.hatch.metadata.hooks.downdoc-readme] path = "README2.adoc"
-
Using an alternative conversion backend
[tool.hatch.metadata.hooks.downdoc-readme] backend = "pandoc-md-mmd"
-
A full example of a pyproject.toml file
[project]
name = "my-cool-project"
version = "0.1.0"
dynamic = ["readme"]
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling", "Pydowndoc[bin]"]
[tool.hatch.metadata.hooks.downdoc-readme]
path = "README2.adoc"
backend = "pandoc-md-mmd"
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
path |
str |
README.adoc |
The location of the AsciiDoc file to be converted to Markdown and used as the project’s README file |
backend |
str |
downdoc-md |
The conversion backend used to convert from AsciiDoc to any other PyPI supported README format. Supported Conversion Backends downdoc-md: Markdown converted by downdocpandoc-md: Pandoc’s Markdown converted by Pandoc & Asciidoctor (via DocBook)pandoc-multi-md: MultiMarkdown converted by Pandoc & Asciidoctor (via DocBook)pandoc-php-md-extra: PHP Markdown Extra converted by Pandoc & Asciidoctor (via DocBook)pandoc-txt: Plaintext converted by Pandoc & Asciidoctor (via DocBook)pandoc-rst: reStructuredText converted by Pandoc & Asciidoctor (via DocBook) |
Upgrading
uv tool upgrade Pydowndoc-bin
If added as a uv project dependency
uv sync --upgrade-package Pydowndoc
If installed using pip
path/to/venv/python -m pip install --upgrade Pydowndoc
Uninstallation
If added as a uv project dependency
uv remove Pydowndoc
If installed as a uv tool
uv tool uninstall Pydowndoc-bin
If installed with pip
path/to/venv/python -m pip uninstall Pydowndoc
Reporting Issues
If there are issues with the Python API for this package, or you are encountering installation problems, please report these on the GitHub issues tracker for this project.
If you have problems with the conversion process of your AsciiDoc files to Markdown, please report these upstream, directly to the downdoc project.
Windows & macOS Wheels
Windows and macOS wheels are provided to enable use of this project on non-linux hosts. However, these versions have not had the same level of testing as the linux version. Therefore, if you encounter any bugs with these other versions, report them on the GitHub issues tracker for this project.
Licencing
The compiled binary of the distributed downdoc software is shared under the MIT licence as described in the upstream project’s licence file.
All other code in this project is distributed under the Apache-2.0 licence.
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 pydowndoc-2.3.0.tar.gz.
File metadata
- Download URL: pydowndoc-2.3.0.tar.gz
- Upload date:
- Size: 22.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a459d5008ed0be25336b7efcc5163fef46977bdd578b5397128314b90f8d33a1
|
|
| MD5 |
bcfc6e6b4545d39169c38217e228ac6a
|
|
| BLAKE2b-256 |
e0987a93d6d31ee5b2738a44c5de27952b9f480abe729c2f311c99a1273cd9d2
|
File details
Details for the file pydowndoc-2.3.0-py3-none-any.whl.
File metadata
- Download URL: pydowndoc-2.3.0-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b83e3cbdc9aeeb36a47ea703673dce02398c5a3ddf8991be2d57c4872ae793a
|
|
| MD5 |
bb29598e0a9f6dc6b66e53ffaad2bc12
|
|
| BLAKE2b-256 |
749c0ceb7376c85a2e201619069870798e854495ea95338dd7b1c8e21647e5aa
|