medium2md-cli 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- medium2md_cli-0.1.0/.gitignore +211 -0
- medium2md_cli-0.1.0/.python-version +1 -0
- medium2md_cli-0.1.0/LICENSE +21 -0
- medium2md_cli-0.1.0/PKG-INFO +237 -0
- medium2md_cli-0.1.0/README.md +205 -0
- medium2md_cli-0.1.0/input/.gitkeep +0 -0
- medium2md_cli-0.1.0/medium2md/__init__.py +0 -0
- medium2md_cli-0.1.0/medium2md/cli.py +102 -0
- medium2md_cli-0.1.0/medium2md/main.py +6 -0
- medium2md_cli-0.1.0/medium2md/pipeline.py +229 -0
- medium2md_cli-0.1.0/project-plan.md +445 -0
- medium2md_cli-0.1.0/pyproject.toml +49 -0
- medium2md_cli-0.1.0/uv.lock +744 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
208
|
+
|
|
209
|
+
# Input directory for Medium export ZIP files (copy your export.zip here)
|
|
210
|
+
input/*
|
|
211
|
+
!input/.gitkeep
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Edgar Bermudez
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: medium2md-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Convert a Medium export ZIP into Hugo-ready Markdown page bundles with localized images.
|
|
5
|
+
Project-URL: Homepage, https://github.com/edgarbc/medium2md
|
|
6
|
+
Project-URL: Repository, https://github.com/edgarbc/medium2md
|
|
7
|
+
Project-URL: Documentation, https://github.com/edgarbc/medium2md#readme
|
|
8
|
+
Author: Edgar Bermudez
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: export,hugo,markdown,medium,migration,static-site
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Text Processing :: Markup
|
|
19
|
+
Requires-Python: >=3.13
|
|
20
|
+
Requires-Dist: beautifulsoup4>=4.14.3
|
|
21
|
+
Requires-Dist: httpx>=0.28.1
|
|
22
|
+
Requires-Dist: lxml>=6.0.2
|
|
23
|
+
Requires-Dist: markdownify>=1.2.2
|
|
24
|
+
Requires-Dist: python-dateutil>=2.9.0.post0
|
|
25
|
+
Requires-Dist: python-slugify>=8.0.4
|
|
26
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
27
|
+
Requires-Dist: rich>=14.3.3
|
|
28
|
+
Requires-Dist: typer>=0.24.1
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: twine>=6.0; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# medium2md
|
|
34
|
+
|
|
35
|
+
[](https://pypi.org/project/medium2md-cli/)
|
|
36
|
+
[](https://pypi.org/project/medium2md-cli/)
|
|
37
|
+
[](https://opensource.org/licenses/MIT)
|
|
38
|
+
|
|
39
|
+
> Convert a Medium export ZIP into clean, Hugo-ready Markdown page bundles.
|
|
40
|
+
|
|
41
|
+
**medium2md** is a CLI tool that transforms Medium's HTML export into properly structured [Hugo](https://gohugo.io/) content using page bundles — enabling full ownership of your content and a clean, reproducible migration from Medium to Hugo.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Table of Contents
|
|
46
|
+
|
|
47
|
+
- [Why This Exists](#why-this-exists)
|
|
48
|
+
- [Features](#features)
|
|
49
|
+
- [Installation](#installation)
|
|
50
|
+
- [Usage](#usage)
|
|
51
|
+
- [Output Structure](#output-structure)
|
|
52
|
+
- [Project Structure](#project-structure)
|
|
53
|
+
- [Development Roadmap](#development-roadmap)
|
|
54
|
+
- [Contributing](#contributing)
|
|
55
|
+
- [License](#license)
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Why This Exists
|
|
60
|
+
|
|
61
|
+
Medium allows you to export your account data as a ZIP archive, but the raw export:
|
|
62
|
+
|
|
63
|
+
- Contains unstructured HTML
|
|
64
|
+
- Includes inconsistent metadata
|
|
65
|
+
- References remote image URLs
|
|
66
|
+
|
|
67
|
+
**medium2md** solves this by providing:
|
|
68
|
+
|
|
69
|
+
| Feature | Description |
|
|
70
|
+
|---|---|
|
|
71
|
+
| HTML → Markdown | Converts Medium HTML posts to clean Markdown |
|
|
72
|
+
| Hugo front matter | Generates YAML front matter from post metadata |
|
|
73
|
+
| Image localization | Downloads remote images into each bundle; copies local images when present in the export |
|
|
74
|
+
| Canonical URL | Preserves the original Medium URL |
|
|
75
|
+
| Conversion reports | Summarizes what was converted and what was skipped |
|
|
76
|
+
| Incremental re-runs | *(planned)* Re-run only changed posts |
|
|
77
|
+
|
|
78
|
+
This tool is designed to be **deterministic**, **reproducible**, and **CI-friendly**.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Features
|
|
83
|
+
|
|
84
|
+
### MVP (current)
|
|
85
|
+
|
|
86
|
+
- Convert Medium export ZIP (posts under `posts/` in the export)
|
|
87
|
+
- Extract title and canonical URL; generate slug
|
|
88
|
+
- Convert HTML to Markdown
|
|
89
|
+
- Create Hugo page bundles with `index.md` and optional `images/`
|
|
90
|
+
- Image localization: download remote images into the bundle; copy local images when present in the export
|
|
91
|
+
- Basic slug collision handling (`slug-2`, `slug-3`, …)
|
|
92
|
+
- Terminal progress and summary; per-post image count; prompt to create missing output dir
|
|
93
|
+
|
|
94
|
+
### Planned
|
|
95
|
+
|
|
96
|
+
- Extract date and optional metadata (tags, etc.) into front matter
|
|
97
|
+
- Incremental runs via state file
|
|
98
|
+
- Embed detection and shortcode conversion (YouTube, Twitter, Gist)
|
|
99
|
+
- Pandoc backend option
|
|
100
|
+
- Verification command
|
|
101
|
+
- Theme-specific front matter mapping
|
|
102
|
+
- Conversion report (e.g. JSON/file)
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Installation
|
|
107
|
+
|
|
108
|
+
This project uses [uv](https://github.com/astral-sh/uv) for dependency management.
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
git clone https://github.com/edgarbc/medium2md.git
|
|
112
|
+
cd medium2md
|
|
113
|
+
uv sync
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Once published to PyPI, install with:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
pip install medium2md-cli
|
|
120
|
+
# or with uv:
|
|
121
|
+
uv tool install medium2md-cli
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The CLI command is still `medium2md`.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Usage
|
|
129
|
+
|
|
130
|
+
Copy your Medium export ZIP into the `input/` directory (already set up and git-ignored):
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
cp ~/Downloads/medium-export.zip input/
|
|
134
|
+
uv run medium2md input/medium-export.zip --out ../blog/content/posts
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
> **Note:** The `input/` directory is tracked by git (via `.gitkeep`) so it exists after a fresh clone, but its contents are ignored — your ZIP files will never be accidentally committed.
|
|
138
|
+
|
|
139
|
+
### Front Matter Example
|
|
140
|
+
|
|
141
|
+
Each converted post produces an `index.md` with Hugo-compatible YAML front matter. Current output:
|
|
142
|
+
|
|
143
|
+
```yaml
|
|
144
|
+
---
|
|
145
|
+
title: "My Post Title"
|
|
146
|
+
draft: true
|
|
147
|
+
slug: "my-post-slug"
|
|
148
|
+
medium:
|
|
149
|
+
canonical: "https://medium.com/@you/post-slug"
|
|
150
|
+
---
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Additional keys (e.g. `date`, `lastmod`, `tags`) are planned.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Output Structure
|
|
158
|
+
|
|
159
|
+
Each Medium post becomes a Hugo page bundle. Image links in the Markdown point into the bundle’s `images/` folder (remote images are downloaded; local images from the export are copied):
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
content/posts/
|
|
163
|
+
└── my-post-slug/
|
|
164
|
+
├── index.md
|
|
165
|
+
└── images/
|
|
166
|
+
├── 1.png
|
|
167
|
+
├── 2.jpg
|
|
168
|
+
└── …
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Project Structure
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
medium2md/
|
|
177
|
+
├── medium2md/
|
|
178
|
+
│ ├── __init__.py
|
|
179
|
+
│ ├── cli.py
|
|
180
|
+
│ ├── pipeline.py
|
|
181
|
+
│ └── main.py
|
|
182
|
+
├── pyproject.toml
|
|
183
|
+
├── README.md
|
|
184
|
+
├── project-plan.md
|
|
185
|
+
└── input/
|
|
186
|
+
└── medium-export.zip
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Pipeline Architecture
|
|
190
|
+
|
|
191
|
+
medium2md follows a layered pipeline:
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
ZIP → extract → find posts → parse HTML → localize images (copy/download) → Markdown conversion → front matter + Hugo bundle write
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
> **Philosophy:** Correctness first, cleverness later.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Development Roadmap
|
|
202
|
+
|
|
203
|
+
| Milestone | Focus | Status |
|
|
204
|
+
|---|---|---|
|
|
205
|
+
| 1 — MVP | ZIP ingestion, HTML→Markdown, Hugo bundle writing, image localization | ✅ Done |
|
|
206
|
+
| 2 — Robustness | Incremental state tracking, metadata fallback, verify command | 📋 Planned |
|
|
207
|
+
| 3 — Polish | Embed conversion, theme config mapping, Pandoc backend, internal link rewriting | 📋 Planned |
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Contributing
|
|
212
|
+
|
|
213
|
+
Contributions are welcome! To get started:
|
|
214
|
+
|
|
215
|
+
1. Fork the repository
|
|
216
|
+
2. Create a feature branch (`git checkout -b feat/my-feature`)
|
|
217
|
+
3. Make your changes
|
|
218
|
+
4. Open a pull request (run `uv run medium2md --help` to confirm the CLI works)
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Publishing to PyPI (maintainers)
|
|
223
|
+
|
|
224
|
+
1. Bump `version` in `pyproject.toml`.
|
|
225
|
+
2. Build: `uv build` (creates `dist/`).
|
|
226
|
+
3. Install dev deps and upload: `uv sync --extra dev` then `uv run twine upload dist/*` (requires a [PyPI API token](https://pypi.org/help/#apitoken); use `__token__` as username).
|
|
227
|
+
4. Optionally tag the release: `git tag v0.1.0 && git push --tags`.
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
> Built by [Edgar Bermudez](https://github.com/edgarbc) and [GitHub Copilot](https://github.com/features/copilot) with 💖 to enable long-term content ownership and reproducible publishing workflows.
|
|
236
|
+
>
|
|
237
|
+
> Not affiliated with Medium or any of its subsidiaries.
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# medium2md
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/medium2md-cli/)
|
|
4
|
+
[](https://pypi.org/project/medium2md-cli/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
> Convert a Medium export ZIP into clean, Hugo-ready Markdown page bundles.
|
|
8
|
+
|
|
9
|
+
**medium2md** is a CLI tool that transforms Medium's HTML export into properly structured [Hugo](https://gohugo.io/) content using page bundles — enabling full ownership of your content and a clean, reproducible migration from Medium to Hugo.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Table of Contents
|
|
14
|
+
|
|
15
|
+
- [Why This Exists](#why-this-exists)
|
|
16
|
+
- [Features](#features)
|
|
17
|
+
- [Installation](#installation)
|
|
18
|
+
- [Usage](#usage)
|
|
19
|
+
- [Output Structure](#output-structure)
|
|
20
|
+
- [Project Structure](#project-structure)
|
|
21
|
+
- [Development Roadmap](#development-roadmap)
|
|
22
|
+
- [Contributing](#contributing)
|
|
23
|
+
- [License](#license)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Why This Exists
|
|
28
|
+
|
|
29
|
+
Medium allows you to export your account data as a ZIP archive, but the raw export:
|
|
30
|
+
|
|
31
|
+
- Contains unstructured HTML
|
|
32
|
+
- Includes inconsistent metadata
|
|
33
|
+
- References remote image URLs
|
|
34
|
+
|
|
35
|
+
**medium2md** solves this by providing:
|
|
36
|
+
|
|
37
|
+
| Feature | Description |
|
|
38
|
+
|---|---|
|
|
39
|
+
| HTML → Markdown | Converts Medium HTML posts to clean Markdown |
|
|
40
|
+
| Hugo front matter | Generates YAML front matter from post metadata |
|
|
41
|
+
| Image localization | Downloads remote images into each bundle; copies local images when present in the export |
|
|
42
|
+
| Canonical URL | Preserves the original Medium URL |
|
|
43
|
+
| Conversion reports | Summarizes what was converted and what was skipped |
|
|
44
|
+
| Incremental re-runs | *(planned)* Re-run only changed posts |
|
|
45
|
+
|
|
46
|
+
This tool is designed to be **deterministic**, **reproducible**, and **CI-friendly**.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
|
|
52
|
+
### MVP (current)
|
|
53
|
+
|
|
54
|
+
- Convert Medium export ZIP (posts under `posts/` in the export)
|
|
55
|
+
- Extract title and canonical URL; generate slug
|
|
56
|
+
- Convert HTML to Markdown
|
|
57
|
+
- Create Hugo page bundles with `index.md` and optional `images/`
|
|
58
|
+
- Image localization: download remote images into the bundle; copy local images when present in the export
|
|
59
|
+
- Basic slug collision handling (`slug-2`, `slug-3`, …)
|
|
60
|
+
- Terminal progress and summary; per-post image count; prompt to create missing output dir
|
|
61
|
+
|
|
62
|
+
### Planned
|
|
63
|
+
|
|
64
|
+
- Extract date and optional metadata (tags, etc.) into front matter
|
|
65
|
+
- Incremental runs via state file
|
|
66
|
+
- Embed detection and shortcode conversion (YouTube, Twitter, Gist)
|
|
67
|
+
- Pandoc backend option
|
|
68
|
+
- Verification command
|
|
69
|
+
- Theme-specific front matter mapping
|
|
70
|
+
- Conversion report (e.g. JSON/file)
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Installation
|
|
75
|
+
|
|
76
|
+
This project uses [uv](https://github.com/astral-sh/uv) for dependency management.
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
git clone https://github.com/edgarbc/medium2md.git
|
|
80
|
+
cd medium2md
|
|
81
|
+
uv sync
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Once published to PyPI, install with:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pip install medium2md-cli
|
|
88
|
+
# or with uv:
|
|
89
|
+
uv tool install medium2md-cli
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The CLI command is still `medium2md`.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Usage
|
|
97
|
+
|
|
98
|
+
Copy your Medium export ZIP into the `input/` directory (already set up and git-ignored):
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
cp ~/Downloads/medium-export.zip input/
|
|
102
|
+
uv run medium2md input/medium-export.zip --out ../blog/content/posts
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
> **Note:** The `input/` directory is tracked by git (via `.gitkeep`) so it exists after a fresh clone, but its contents are ignored — your ZIP files will never be accidentally committed.
|
|
106
|
+
|
|
107
|
+
### Front Matter Example
|
|
108
|
+
|
|
109
|
+
Each converted post produces an `index.md` with Hugo-compatible YAML front matter. Current output:
|
|
110
|
+
|
|
111
|
+
```yaml
|
|
112
|
+
---
|
|
113
|
+
title: "My Post Title"
|
|
114
|
+
draft: true
|
|
115
|
+
slug: "my-post-slug"
|
|
116
|
+
medium:
|
|
117
|
+
canonical: "https://medium.com/@you/post-slug"
|
|
118
|
+
---
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Additional keys (e.g. `date`, `lastmod`, `tags`) are planned.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Output Structure
|
|
126
|
+
|
|
127
|
+
Each Medium post becomes a Hugo page bundle. Image links in the Markdown point into the bundle’s `images/` folder (remote images are downloaded; local images from the export are copied):
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
content/posts/
|
|
131
|
+
└── my-post-slug/
|
|
132
|
+
├── index.md
|
|
133
|
+
└── images/
|
|
134
|
+
├── 1.png
|
|
135
|
+
├── 2.jpg
|
|
136
|
+
└── …
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Project Structure
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
medium2md/
|
|
145
|
+
├── medium2md/
|
|
146
|
+
│ ├── __init__.py
|
|
147
|
+
│ ├── cli.py
|
|
148
|
+
│ ├── pipeline.py
|
|
149
|
+
│ └── main.py
|
|
150
|
+
├── pyproject.toml
|
|
151
|
+
├── README.md
|
|
152
|
+
├── project-plan.md
|
|
153
|
+
└── input/
|
|
154
|
+
└── medium-export.zip
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Pipeline Architecture
|
|
158
|
+
|
|
159
|
+
medium2md follows a layered pipeline:
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
ZIP → extract → find posts → parse HTML → localize images (copy/download) → Markdown conversion → front matter + Hugo bundle write
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
> **Philosophy:** Correctness first, cleverness later.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Development Roadmap
|
|
170
|
+
|
|
171
|
+
| Milestone | Focus | Status |
|
|
172
|
+
|---|---|---|
|
|
173
|
+
| 1 — MVP | ZIP ingestion, HTML→Markdown, Hugo bundle writing, image localization | ✅ Done |
|
|
174
|
+
| 2 — Robustness | Incremental state tracking, metadata fallback, verify command | 📋 Planned |
|
|
175
|
+
| 3 — Polish | Embed conversion, theme config mapping, Pandoc backend, internal link rewriting | 📋 Planned |
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Contributing
|
|
180
|
+
|
|
181
|
+
Contributions are welcome! To get started:
|
|
182
|
+
|
|
183
|
+
1. Fork the repository
|
|
184
|
+
2. Create a feature branch (`git checkout -b feat/my-feature`)
|
|
185
|
+
3. Make your changes
|
|
186
|
+
4. Open a pull request (run `uv run medium2md --help` to confirm the CLI works)
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Publishing to PyPI (maintainers)
|
|
191
|
+
|
|
192
|
+
1. Bump `version` in `pyproject.toml`.
|
|
193
|
+
2. Build: `uv build` (creates `dist/`).
|
|
194
|
+
3. Install dev deps and upload: `uv sync --extra dev` then `uv run twine upload dist/*` (requires a [PyPI API token](https://pypi.org/help/#apitoken); use `__token__` as username).
|
|
195
|
+
4. Optionally tag the release: `git tag v0.1.0 && git push --tags`.
|
|
196
|
+
|
|
197
|
+
## License
|
|
198
|
+
|
|
199
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
> Built by [Edgar Bermudez](https://github.com/edgarbc) and [GitHub Copilot](https://github.com/features/copilot) with 💖 to enable long-term content ownership and reproducible publishing workflows.
|
|
204
|
+
>
|
|
205
|
+
> Not affiliated with Medium or any of its subsidiaries.
|
|
File without changes
|
|
File without changes
|