Skip to main content

Python wrapper for converting/reducing AsciiDoc files back to Markdown.

Project description

Pydowndoc

Pydowndoc PyPI Version Python Version downdoc Version Tests Status mypy Status pre-commit Status Ruff uv

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?

Installation

Run as a uv tool (no installation necessary)

uvx --from Pydowndoc -- downdoc --version

Add to your uv project/script’s dependencies

uv add Pydowndoc

Install permanently as a uv tool

uv tool install Pydowndoc

Install using pip after creating a virtual environment

path/to/venv/python -m pip install Pydowndoc

CLI Usage

These commands will only work correctly either after installation as a permanent uv tool, or after activating a virtual environment with Pydowndoc installed. Replace the command name downdoc with uvx --from Pydowndoc -- downdoc, to run any of the following commands in an ephemeral envrionment.

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.run(Path("MyNotes.adoc"))

Retrieve the converted file as a string

from pathlib import Path

import pydowndoc

converted_file_contents: str = pydowndoc.run(
    Path("MyNotes.adoc"),
    output="-",
    process_capture_output=True,
).stdout.decode()

Ensure the conversion process executes successfully and output the converted file to the given location (by default your code will continue execution even if conversion fails)

from pathlib import Path

import pydowndoc

pydowndoc.run(
    Path("MyNotes.adoc"),
    output=Path("path/to/output.md"),
    process_check_return_code=True,
)

Use as a Hatch build hook

  1. Ensure the readme field is added to your project.dynamic list within your pyproject.toml file

    [project]
    name = "my-cool-project"
    version = "0.1.0"
    dynamic = ["readme"]
    
  2. Set up your build backend, within your pyproject.toml file

    [build-system]
    build-backend = "hatchling.build"
    requires = ["hatchling", "Pydowndoc"]
    
  3. 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 = {}
    
    1. Using a path to a custom README file

      [tool.hatch.metadata.hooks.downdoc-readme]
      path = "README2.adoc"
      
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"]

[tool.hatch.metadata.hooks.downdoc-readme]
path = "README2.adoc"

Configuration Options

Option Type Default Description
path str README.adoc The location of your AsciiDoc to be converted to Markdown, to be used as the project’s README file

Upgrading

If installed as a uv tool

uv tool upgrade Pydowndoc

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

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 distrubuted under the Apache-2.0 licence.

Project details


Download files

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

Source Distribution

pydowndoc-1.3.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

pydowndoc-1.3.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file pydowndoc-1.3.1.tar.gz.

File metadata

  • Download URL: pydowndoc-1.3.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.20

File hashes

Hashes for pydowndoc-1.3.1.tar.gz
Algorithm Hash digest
SHA256 7984466b2f4ce1fa1b3df09faf24ebcb5bf80671f103f4c663cfef5b5da88df5
MD5 cf33746aceb2de16abee7dc3b759cd45
BLAKE2b-256 631ea60ec221269922fe2a47da441659ada28a8f91ebec8fb6825433fcd68dc9

See more details on using hashes here.

File details

Details for the file pydowndoc-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: pydowndoc-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.20

File hashes

Hashes for pydowndoc-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 40e2f118489ed0b135049ca3be7480d35a7658b6be02fabc92283ae2a77ac4cb
MD5 10172223fb2f8ae5f503e5cd64b028f2
BLAKE2b-256 6dfeb02356696d765191edf3bd6cab4096825fbfc1221268232cf51163e48ce7

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