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

Uploaded Source

Built Distribution

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

Uploaded Python 3

Supported by

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