Skip to main content

Download and convert Medium articles to markdown with images

Project description

Header

GitHub issues GitHub forks GitHub stars GitHub license

Convert your favorite Medium articles into markdown files using Medium2md, a powerful and user-friendly command-line tool. Designed in Python, it extends beyond simple conversion to download all images within the article, saving them locally and integrating them into your markdown file seamlessly.

Medium2md Demo

Table of Contents

Features

  • Efficient Conversion: Download Medium articles as HTML and convert them into clean, readable Markdown files.
  • Image Handling: Download images from the article, save them locally, and update image URLs in the markdown files to point to local paths.
  • Post-Processing: Automatically clean up unnecessary data after conversion.
  • User-Friendly: Interactive CLI interface with progress bars and prompts for an enhanced user experience.

Getting Started

Prerequisites

  • Python 3.8 or later
  • Conda

Installation

  1. Clone the repository:

    git clone https://github.com/siddharthksah/medium2md.git
    
  2. Navigate into the project directory:

    cd medium2md
    
  3. Create a new conda environment and activate it:

    conda create --name medium2md python=3.8 -y
    conda activate medium2md
    
  4. Install the package and its dependencies using setup.py:

    python3 setup.py install
    playwright install
    

    This will automatically install all required packages listed in setup.py's install_requires section.

Usage

Run medium2md with:

python3 src/main.py -u <URL>

Replace with the URL of the Medium article you wish to download. If no URL is provided, the script will prompt you to input one.

When the process is complete, the script will ask if you wish to open the downloaded markdown file in your default editor.

Output

The converted articles are stored in the output directory, which is created in the project's root directory.

Unittests

Running Unittests

To run the unittests for the Medium2md project, navigate to the root directory of the project and use the following command:

python -m unittest discover unittests

This will automatically discover and run all the unittests in the unittests directory.

Please ensure that you have installed the required packages for the project by following the installation instructions in the Getting Started section.

📚 Project Structure

.
├── LICENSE.txt
├── README.md
├── docs
├── output
├── requirements.txt
└── src
    ├── __init__.py
    ├── clean_md.py
    ├── clean_unnecessary_data.py
    ├── download_with_media.py
    ├── html_to_md.py
    ├── main.py
    └── url_to_local.py

🤝 Contributing

We welcome contributions! If you would like to make changes, please submit a pull request. For substantial updates, we request that you open an issue first to discuss the proposed changes.

📃 License

Medium2md is licensed under the terms of the MIT License. For the full text, see the LICENSE file.

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

medium2md-2.0.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

medium2md-2.0.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file medium2md-2.0.0.tar.gz.

File metadata

  • Download URL: medium2md-2.0.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.17

File hashes

Hashes for medium2md-2.0.0.tar.gz
Algorithm Hash digest
SHA256 2c28c5b066a6beddc9d314c933822f0332d7f96e9ad2567f884da8f860539518
MD5 343099c58f4acca065dd4142a7e942e3
BLAKE2b-256 0d547c3235482f9b3987244a13cd850d74589cf03d55bdc1b79539c7d21b1791

See more details on using hashes here.

File details

Details for the file medium2md-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: medium2md-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.17

File hashes

Hashes for medium2md-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f543843d471853825f893ca007ef849d701ca5620c11f166373aa0f2a8c1f5b
MD5 32e525beafe90bd26035b42a2a4de39a
BLAKE2b-256 3b28bc10740a4d119e04b2a0e1137baea067eedd204c1634ca80fc53e0efe17f

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