wordpress-to-markdown 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.
- wordpress_to_markdown-0.1.0/LICENSE +21 -0
- wordpress_to_markdown-0.1.0/MANIFEST.in +4 -0
- wordpress_to_markdown-0.1.0/PKG-INFO +337 -0
- wordpress_to_markdown-0.1.0/README.md +318 -0
- wordpress_to_markdown-0.1.0/pyproject.toml +33 -0
- wordpress_to_markdown-0.1.0/setup.cfg +4 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/__init__.py +3 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/__main__.py +4 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/assembler.py +130 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/cli.py +141 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/commanding.py +580 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/config/__init__.py +1 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/config/loader.py +24 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/core/__init__.py +1 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/core/models.py +49 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/importer/__init__.py +1 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/importer/wordpress_api.py +341 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/processors/__init__.py +1 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/processors/metadata.py +103 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/processors/pipeline.py +43 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/sources/__init__.py +1 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/sources/imported_json.py +64 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown/writer.py +70 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown.egg-info/PKG-INFO +337 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown.egg-info/SOURCES.txt +27 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown.egg-info/dependency_links.txt +1 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown.egg-info/entry_points.txt +2 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown.egg-info/requires.txt +8 -0
- wordpress_to_markdown-0.1.0/src/wordpress_to_markdown.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aues12
|
|
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,337 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wordpress-to-markdown
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Export WordPress posts to Markdown with configurable metadata and output modes.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Repository, https://github.com/Aues12/wordpress-to-markdown
|
|
7
|
+
Project-URL: Issues, https://github.com/Aues12/wordpress-to-markdown/issues
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: markdownify>=1.2.0
|
|
12
|
+
Requires-Dist: PyYAML>=6.0.2
|
|
13
|
+
Requires-Dist: requests>=2.31
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: pytest>=8.4.0; extra == "dev"
|
|
16
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
17
|
+
Requires-Dist: twine>=6.0; extra == "dev"
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# WordPress to Markdown
|
|
21
|
+
|
|
22
|
+
A modular Python library for converting WordPress content into structured, Markdown (including Obsidian-compatible notes) files.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Overview
|
|
27
|
+
|
|
28
|
+
This project provides a clean and extensible pipeline to transform content from WordPress into local files suitable for knowledge management systems like Obsidian.
|
|
29
|
+
|
|
30
|
+
Core pipeline:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
WordPress API → JSON → Process → Assemble → Write
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Features
|
|
39
|
+
|
|
40
|
+
* Fetch posts from WordPress REST API
|
|
41
|
+
* Normalize and process content
|
|
42
|
+
* Convert posts into structured objects
|
|
43
|
+
* Export as Markdown files
|
|
44
|
+
* Build output in `per_post` or `book` mode
|
|
45
|
+
* Optional YAML frontmatter generation
|
|
46
|
+
* Modular architecture (easy to extend)
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Project Structure
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
wordpress-to-markdown/
|
|
54
|
+
├── src/wordpress_to_markdown/
|
|
55
|
+
│ ├── cli.py
|
|
56
|
+
│ ├── commanding.py
|
|
57
|
+
│ ├── config/
|
|
58
|
+
│ ├── core/
|
|
59
|
+
│ ├── importer/
|
|
60
|
+
│ ├── processors/
|
|
61
|
+
│ ├── sources/
|
|
62
|
+
│ ├── assembler.py
|
|
63
|
+
│ └── writer.py
|
|
64
|
+
├── tests/
|
|
65
|
+
├── config.json
|
|
66
|
+
└── pyproject.toml
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Installation
|
|
72
|
+
|
|
73
|
+
Requires Python 3.10 or newer.
|
|
74
|
+
|
|
75
|
+
### Install from PyPI (after the first release)
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install wordpress-to-markdown
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Install from GitHub (available now)
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install git+https://github.com/Aues12/wordpress-to-markdown.git
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Clone the repository
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
git clone https://github.com/Aues12/wordpress-to-markdown.git
|
|
91
|
+
cd wordpress-to-markdown
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Quickstart
|
|
95
|
+
|
|
96
|
+
(Optional but recommended) Create and activate a virtual environment:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
python -m venv venv
|
|
100
|
+
source venv/bin/activate
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Development installation
|
|
104
|
+
|
|
105
|
+
With pip:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
python -m pip install -e '.[dev]'
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
With uv (using `uv.lock`):
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
uv sync --locked --extra dev
|
|
115
|
+
uv run wordpress-to-markdown --help
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Dependencies:
|
|
119
|
+
|
|
120
|
+
* requests
|
|
121
|
+
* PyYAML
|
|
122
|
+
* markdownify
|
|
123
|
+
|
|
124
|
+
For running tests:
|
|
125
|
+
|
|
126
|
+
* pytest
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Usage
|
|
131
|
+
|
|
132
|
+
### 1. Fetch data from WordPress
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
from wordpress_to_markdown.importer.wordpress_api import export_posts_to_json
|
|
136
|
+
|
|
137
|
+
export_posts_to_json(
|
|
138
|
+
base_url="https://your-site.com",
|
|
139
|
+
output_file="data/imported.json"
|
|
140
|
+
)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Use this manual fetch step when you want to generate or refresh `data/imported.json`
|
|
144
|
+
outside the CLI workflow. In normal usage, `wordpress-to-markdown` already checks for the
|
|
145
|
+
JSON file and fetches it automatically when needed, or when you pass `--refresh`.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
### 2. Configure the CLI
|
|
150
|
+
|
|
151
|
+
Use `--config /path/to/config.json` to select a configuration file. Relative `json_file` and `output_dir` paths are resolved from the configuration file's directory, not the shell's working directory.
|
|
152
|
+
|
|
153
|
+
Create/edit the `config.json` file in the project root:
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"wordpress": {
|
|
158
|
+
"base_url": "https://your-site.com"
|
|
159
|
+
},
|
|
160
|
+
"paths": {
|
|
161
|
+
"json_file": "data/imported.json",
|
|
162
|
+
"output_dir": "output"
|
|
163
|
+
},
|
|
164
|
+
"frontmatter": {
|
|
165
|
+
"include_frontmatter": false,
|
|
166
|
+
"fields": [
|
|
167
|
+
"title",
|
|
168
|
+
"date",
|
|
169
|
+
"modified",
|
|
170
|
+
"slug",
|
|
171
|
+
"category_names"
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
### 3. Run the pipeline
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
wordpress-to-markdown
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
This will:
|
|
186
|
+
|
|
187
|
+
* Load `config.json`
|
|
188
|
+
* Reuse existing JSON or fetch fresh data from WordPress
|
|
189
|
+
* Load JSON
|
|
190
|
+
* Process posts
|
|
191
|
+
* Assemble output
|
|
192
|
+
* Write Markdown files to the configured output directory
|
|
193
|
+
|
|
194
|
+
Available CLI options:
|
|
195
|
+
|
|
196
|
+
* `--refresh` fetches fresh data from WordPress before building
|
|
197
|
+
* `--order {newest,oldest}` controls post selection order before limiting
|
|
198
|
+
* `--write_order {newest,oldest}` controls ordering inside the written output
|
|
199
|
+
* `--limit N` limits the number of posts to build
|
|
200
|
+
* `--mode {per_post,book}` switches between one-file-per-post and combined book output
|
|
201
|
+
* `--frontmatter` includes YAML frontmatter in the assembled output
|
|
202
|
+
* `--excerpt` includes each WordPress excerpt before the post content (disabled by default)
|
|
203
|
+
* `--content-format {markdown,html}` converts post and excerpt HTML to Markdown (default), or preserves the imported HTML inside the `.md` output
|
|
204
|
+
|
|
205
|
+
Cached exports created before excerpt support do not contain this field. Use
|
|
206
|
+
`--refresh --excerpt` once to fetch excerpts from WordPress and rebuild them.
|
|
207
|
+
|
|
208
|
+
Examples:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
# Build the 10 newest posts as individual markdown files
|
|
212
|
+
wordpress-to-markdown --order newest --limit 10 --mode per_post
|
|
213
|
+
|
|
214
|
+
# Build a single combined book in oldest-to-newest order
|
|
215
|
+
wordpress-to-markdown --order newest --limit 20 --write_order oldest --mode book
|
|
216
|
+
|
|
217
|
+
# Build individual files with WordPress excerpts below each title
|
|
218
|
+
wordpress-to-markdown --mode per_post --excerpt
|
|
219
|
+
|
|
220
|
+
# Preserve imported HTML in Markdown files
|
|
221
|
+
wordpress-to-markdown --content-format html --excerpt
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Testing and packaging
|
|
227
|
+
|
|
228
|
+
GitHub Actions runs the test suite with pip and uv on Python 3.10–3.13, then builds and checks both distributions. It also tests the installed wheel outside the repository.
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
pip install -e '.[dev]'
|
|
232
|
+
python -m pytest
|
|
233
|
+
python -m build
|
|
234
|
+
python -m twine check dist/*
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
The implementation lives in `src/wordpress_to_markdown/`; import modules through `wordpress_to_markdown`. For example, `from wordpress_to_markdown.config.loader import load_config`. Use `wordpress-to-markdown --config /absolute/path/to/config.json` from any working directory; paths inside the config are relative to that file.
|
|
238
|
+
|
|
239
|
+
## Testing
|
|
240
|
+
|
|
241
|
+
Run the test suite with:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
python -m pytest
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
If `pytest` is not installed yet, install it with:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
pip install pytest
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Core Concepts
|
|
256
|
+
|
|
257
|
+
### Post
|
|
258
|
+
|
|
259
|
+
Represents content during processing.
|
|
260
|
+
|
|
261
|
+
### DocumentUnit
|
|
262
|
+
|
|
263
|
+
Represents write-ready output.
|
|
264
|
+
|
|
265
|
+
### Pipeline
|
|
266
|
+
|
|
267
|
+
A sequence of transformations applied to each post.
|
|
268
|
+
|
|
269
|
+
### Assembler
|
|
270
|
+
|
|
271
|
+
Defines how posts are grouped (e.g., per_post, corpus).
|
|
272
|
+
|
|
273
|
+
### Writer
|
|
274
|
+
|
|
275
|
+
Handles output format (e.g., markdown, docx).
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## Current Capabilities
|
|
280
|
+
|
|
281
|
+
* per_post assembly
|
|
282
|
+
* Book assembly
|
|
283
|
+
* Markdown export
|
|
284
|
+
* Turkish-aware slug generation
|
|
285
|
+
* Basic metadata normalization
|
|
286
|
+
* HTML to Markdown conversion
|
|
287
|
+
* Optional YAML frontmatter
|
|
288
|
+
* Config-driven output directory
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## Future Roadmap
|
|
293
|
+
|
|
294
|
+
### Processing
|
|
295
|
+
|
|
296
|
+
* Markdown cleaning
|
|
297
|
+
* Link conversion (URL → wikilinks)
|
|
298
|
+
|
|
299
|
+
### Assembly
|
|
300
|
+
|
|
301
|
+
* Corpus mode
|
|
302
|
+
|
|
303
|
+
### Writer
|
|
304
|
+
|
|
305
|
+
* Additional output formats
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## Design Principles
|
|
310
|
+
|
|
311
|
+
* Modular architecture
|
|
312
|
+
* Clear separation of concerns
|
|
313
|
+
* Stateless processing
|
|
314
|
+
* Extensibility over complexity
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Example Output
|
|
319
|
+
|
|
320
|
+
```
|
|
321
|
+
output/
|
|
322
|
+
├─ post-1.md
|
|
323
|
+
├─ post-2.md
|
|
324
|
+
└─ post-3.md
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## License
|
|
330
|
+
|
|
331
|
+
MIT
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Final Note
|
|
336
|
+
|
|
337
|
+
This project is designed as a foundation for building flexible content pipelines and personal knowledge systems.
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
# WordPress to Markdown
|
|
2
|
+
|
|
3
|
+
A modular Python library for converting WordPress content into structured, Markdown (including Obsidian-compatible notes) files.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This project provides a clean and extensible pipeline to transform content from WordPress into local files suitable for knowledge management systems like Obsidian.
|
|
10
|
+
|
|
11
|
+
Core pipeline:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
WordPress API → JSON → Process → Assemble → Write
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
* Fetch posts from WordPress REST API
|
|
22
|
+
* Normalize and process content
|
|
23
|
+
* Convert posts into structured objects
|
|
24
|
+
* Export as Markdown files
|
|
25
|
+
* Build output in `per_post` or `book` mode
|
|
26
|
+
* Optional YAML frontmatter generation
|
|
27
|
+
* Modular architecture (easy to extend)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Project Structure
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
wordpress-to-markdown/
|
|
35
|
+
├── src/wordpress_to_markdown/
|
|
36
|
+
│ ├── cli.py
|
|
37
|
+
│ ├── commanding.py
|
|
38
|
+
│ ├── config/
|
|
39
|
+
│ ├── core/
|
|
40
|
+
│ ├── importer/
|
|
41
|
+
│ ├── processors/
|
|
42
|
+
│ ├── sources/
|
|
43
|
+
│ ├── assembler.py
|
|
44
|
+
│ └── writer.py
|
|
45
|
+
├── tests/
|
|
46
|
+
├── config.json
|
|
47
|
+
└── pyproject.toml
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
Requires Python 3.10 or newer.
|
|
55
|
+
|
|
56
|
+
### Install from PyPI (after the first release)
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install wordpress-to-markdown
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Install from GitHub (available now)
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install git+https://github.com/Aues12/wordpress-to-markdown.git
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Clone the repository
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
git clone https://github.com/Aues12/wordpress-to-markdown.git
|
|
72
|
+
cd wordpress-to-markdown
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Quickstart
|
|
76
|
+
|
|
77
|
+
(Optional but recommended) Create and activate a virtual environment:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
python -m venv venv
|
|
81
|
+
source venv/bin/activate
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Development installation
|
|
85
|
+
|
|
86
|
+
With pip:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
python -m pip install -e '.[dev]'
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
With uv (using `uv.lock`):
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
uv sync --locked --extra dev
|
|
96
|
+
uv run wordpress-to-markdown --help
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Dependencies:
|
|
100
|
+
|
|
101
|
+
* requests
|
|
102
|
+
* PyYAML
|
|
103
|
+
* markdownify
|
|
104
|
+
|
|
105
|
+
For running tests:
|
|
106
|
+
|
|
107
|
+
* pytest
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Usage
|
|
112
|
+
|
|
113
|
+
### 1. Fetch data from WordPress
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
from wordpress_to_markdown.importer.wordpress_api import export_posts_to_json
|
|
117
|
+
|
|
118
|
+
export_posts_to_json(
|
|
119
|
+
base_url="https://your-site.com",
|
|
120
|
+
output_file="data/imported.json"
|
|
121
|
+
)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Use this manual fetch step when you want to generate or refresh `data/imported.json`
|
|
125
|
+
outside the CLI workflow. In normal usage, `wordpress-to-markdown` already checks for the
|
|
126
|
+
JSON file and fetches it automatically when needed, or when you pass `--refresh`.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
### 2. Configure the CLI
|
|
131
|
+
|
|
132
|
+
Use `--config /path/to/config.json` to select a configuration file. Relative `json_file` and `output_dir` paths are resolved from the configuration file's directory, not the shell's working directory.
|
|
133
|
+
|
|
134
|
+
Create/edit the `config.json` file in the project root:
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"wordpress": {
|
|
139
|
+
"base_url": "https://your-site.com"
|
|
140
|
+
},
|
|
141
|
+
"paths": {
|
|
142
|
+
"json_file": "data/imported.json",
|
|
143
|
+
"output_dir": "output"
|
|
144
|
+
},
|
|
145
|
+
"frontmatter": {
|
|
146
|
+
"include_frontmatter": false,
|
|
147
|
+
"fields": [
|
|
148
|
+
"title",
|
|
149
|
+
"date",
|
|
150
|
+
"modified",
|
|
151
|
+
"slug",
|
|
152
|
+
"category_names"
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### 3. Run the pipeline
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
wordpress-to-markdown
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
This will:
|
|
167
|
+
|
|
168
|
+
* Load `config.json`
|
|
169
|
+
* Reuse existing JSON or fetch fresh data from WordPress
|
|
170
|
+
* Load JSON
|
|
171
|
+
* Process posts
|
|
172
|
+
* Assemble output
|
|
173
|
+
* Write Markdown files to the configured output directory
|
|
174
|
+
|
|
175
|
+
Available CLI options:
|
|
176
|
+
|
|
177
|
+
* `--refresh` fetches fresh data from WordPress before building
|
|
178
|
+
* `--order {newest,oldest}` controls post selection order before limiting
|
|
179
|
+
* `--write_order {newest,oldest}` controls ordering inside the written output
|
|
180
|
+
* `--limit N` limits the number of posts to build
|
|
181
|
+
* `--mode {per_post,book}` switches between one-file-per-post and combined book output
|
|
182
|
+
* `--frontmatter` includes YAML frontmatter in the assembled output
|
|
183
|
+
* `--excerpt` includes each WordPress excerpt before the post content (disabled by default)
|
|
184
|
+
* `--content-format {markdown,html}` converts post and excerpt HTML to Markdown (default), or preserves the imported HTML inside the `.md` output
|
|
185
|
+
|
|
186
|
+
Cached exports created before excerpt support do not contain this field. Use
|
|
187
|
+
`--refresh --excerpt` once to fetch excerpts from WordPress and rebuild them.
|
|
188
|
+
|
|
189
|
+
Examples:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# Build the 10 newest posts as individual markdown files
|
|
193
|
+
wordpress-to-markdown --order newest --limit 10 --mode per_post
|
|
194
|
+
|
|
195
|
+
# Build a single combined book in oldest-to-newest order
|
|
196
|
+
wordpress-to-markdown --order newest --limit 20 --write_order oldest --mode book
|
|
197
|
+
|
|
198
|
+
# Build individual files with WordPress excerpts below each title
|
|
199
|
+
wordpress-to-markdown --mode per_post --excerpt
|
|
200
|
+
|
|
201
|
+
# Preserve imported HTML in Markdown files
|
|
202
|
+
wordpress-to-markdown --content-format html --excerpt
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Testing and packaging
|
|
208
|
+
|
|
209
|
+
GitHub Actions runs the test suite with pip and uv on Python 3.10–3.13, then builds and checks both distributions. It also tests the installed wheel outside the repository.
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
pip install -e '.[dev]'
|
|
213
|
+
python -m pytest
|
|
214
|
+
python -m build
|
|
215
|
+
python -m twine check dist/*
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
The implementation lives in `src/wordpress_to_markdown/`; import modules through `wordpress_to_markdown`. For example, `from wordpress_to_markdown.config.loader import load_config`. Use `wordpress-to-markdown --config /absolute/path/to/config.json` from any working directory; paths inside the config are relative to that file.
|
|
219
|
+
|
|
220
|
+
## Testing
|
|
221
|
+
|
|
222
|
+
Run the test suite with:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
python -m pytest
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
If `pytest` is not installed yet, install it with:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
pip install pytest
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Core Concepts
|
|
237
|
+
|
|
238
|
+
### Post
|
|
239
|
+
|
|
240
|
+
Represents content during processing.
|
|
241
|
+
|
|
242
|
+
### DocumentUnit
|
|
243
|
+
|
|
244
|
+
Represents write-ready output.
|
|
245
|
+
|
|
246
|
+
### Pipeline
|
|
247
|
+
|
|
248
|
+
A sequence of transformations applied to each post.
|
|
249
|
+
|
|
250
|
+
### Assembler
|
|
251
|
+
|
|
252
|
+
Defines how posts are grouped (e.g., per_post, corpus).
|
|
253
|
+
|
|
254
|
+
### Writer
|
|
255
|
+
|
|
256
|
+
Handles output format (e.g., markdown, docx).
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Current Capabilities
|
|
261
|
+
|
|
262
|
+
* per_post assembly
|
|
263
|
+
* Book assembly
|
|
264
|
+
* Markdown export
|
|
265
|
+
* Turkish-aware slug generation
|
|
266
|
+
* Basic metadata normalization
|
|
267
|
+
* HTML to Markdown conversion
|
|
268
|
+
* Optional YAML frontmatter
|
|
269
|
+
* Config-driven output directory
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Future Roadmap
|
|
274
|
+
|
|
275
|
+
### Processing
|
|
276
|
+
|
|
277
|
+
* Markdown cleaning
|
|
278
|
+
* Link conversion (URL → wikilinks)
|
|
279
|
+
|
|
280
|
+
### Assembly
|
|
281
|
+
|
|
282
|
+
* Corpus mode
|
|
283
|
+
|
|
284
|
+
### Writer
|
|
285
|
+
|
|
286
|
+
* Additional output formats
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Design Principles
|
|
291
|
+
|
|
292
|
+
* Modular architecture
|
|
293
|
+
* Clear separation of concerns
|
|
294
|
+
* Stateless processing
|
|
295
|
+
* Extensibility over complexity
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## Example Output
|
|
300
|
+
|
|
301
|
+
```
|
|
302
|
+
output/
|
|
303
|
+
├─ post-1.md
|
|
304
|
+
├─ post-2.md
|
|
305
|
+
└─ post-3.md
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## License
|
|
311
|
+
|
|
312
|
+
MIT
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## Final Note
|
|
317
|
+
|
|
318
|
+
This project is designed as a foundation for building flexible content pipelines and personal knowledge systems.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "wordpress-to-markdown"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Export WordPress posts to Markdown with configurable metadata and output modes."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"markdownify>=1.2.0",
|
|
14
|
+
"PyYAML>=6.0.2",
|
|
15
|
+
"requests>=2.31",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
wordpress-to-markdown = "wordpress_to_markdown.cli:main"
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Repository = "https://github.com/Aues12/wordpress-to-markdown"
|
|
23
|
+
Issues = "https://github.com/Aues12/wordpress-to-markdown/issues"
|
|
24
|
+
|
|
25
|
+
[project.optional-dependencies]
|
|
26
|
+
dev = ["pytest>=8.4.0", "build>=1.2", "twine>=6.0"]
|
|
27
|
+
|
|
28
|
+
[tool.setuptools.packages.find]
|
|
29
|
+
where = ["src"]
|
|
30
|
+
|
|
31
|
+
[tool.pytest.ini_options]
|
|
32
|
+
testpaths = ["tests"]
|
|
33
|
+
pythonpath = ["src"]
|