webdown 0.4.1__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.
- webdown-0.4.1/LICENSE +21 -0
- webdown-0.4.1/PKG-INFO +341 -0
- webdown-0.4.1/README.md +314 -0
- webdown-0.4.1/pyproject.toml +89 -0
- webdown-0.4.1/webdown/__init__.py +77 -0
- webdown-0.4.1/webdown/cli.py +284 -0
- webdown-0.4.1/webdown/converter.py +422 -0
- webdown-0.4.1/webdown/tests/__init__.py +1 -0
- webdown-0.4.1/webdown/tests/test_cli.py +334 -0
- webdown-0.4.1/webdown/tests/test_converter.py +416 -0
- webdown-0.4.1/webdown/tests/test_integration.py +95 -0
webdown-0.4.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Travis Cole
|
|
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.
|
webdown-0.4.1/PKG-INFO
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: webdown
|
|
3
|
+
Version: 0.4.1
|
|
4
|
+
Summary: Convert web pages to markdown
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: web,markdown,html,converter
|
|
7
|
+
Author: Travis Cole
|
|
8
|
+
Author-email: kelp@plek.org
|
|
9
|
+
Requires-Python: >=3.10,<4.0
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Requires-Dist: beautifulsoup4 (>=4.13.3,<5.0.0)
|
|
19
|
+
Requires-Dist: html2text (>=2024.2.26,<2025.0.0)
|
|
20
|
+
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
21
|
+
Requires-Dist: tqdm (>=4.67.1,<5.0.0)
|
|
22
|
+
Project-URL: Documentation, https://github.com/kelp/webdown/tree/main/docs
|
|
23
|
+
Project-URL: Homepage, https://github.com/kelp/webdown
|
|
24
|
+
Project-URL: Repository, https://github.com/kelp/webdown
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# Webdown
|
|
28
|
+
|
|
29
|
+
[](https://github.com/kelp/webdown/actions/workflows/python-tests.yml)
|
|
30
|
+
[](https://codecov.io/gh/kelp/webdown)
|
|
31
|
+
[](https://badge.fury.io/py/webdown)
|
|
32
|
+
[](https://pypi.org/project/webdown/)
|
|
33
|
+
[](https://opensource.org/licenses/MIT)
|
|
34
|
+
|
|
35
|
+
A Python CLI tool for converting web pages to clean, readable Markdown format. Webdown makes it easy
|
|
36
|
+
to extract content from websites for documentation, notes, content migration, or offline reading.
|
|
37
|
+
|
|
38
|
+
I made this tool specifically so I could download documentation, convert it to Markdown and feed
|
|
39
|
+
it into an LLM coding tool.
|
|
40
|
+
|
|
41
|
+
## Why Webdown?
|
|
42
|
+
|
|
43
|
+
- **Clean Conversion**: Produces readable Markdown without formatting artifacts
|
|
44
|
+
- **Selective Extraction**: Target specific page sections with CSS selectors
|
|
45
|
+
- **Customization Options**: Control links, images, text wrapping, and more
|
|
46
|
+
- **Progress Tracking**: Visual download progress for large pages with `-p` flag
|
|
47
|
+
- **Python Integration**: Use as a CLI tool or integrate into your Python projects
|
|
48
|
+
|
|
49
|
+
## Use Cases
|
|
50
|
+
|
|
51
|
+
### Documentation for AI Coding Assistants
|
|
52
|
+
|
|
53
|
+
Webdown is particularly useful for preparing documentation to use with AI-assisted coding tools like Claude Code, GitHub Copilot, or ChatGPT:
|
|
54
|
+
|
|
55
|
+
- Convert technical documentation into clean Markdown for AI context
|
|
56
|
+
- Extract only the relevant parts of large documentation pages using CSS selectors
|
|
57
|
+
- Strip out images and formatting that might consume token context
|
|
58
|
+
- Generate well-structured tables of contents for better navigation
|
|
59
|
+
- Batch process API documentation for library-specific assistance
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Example: Convert API docs and store for AI coding context
|
|
63
|
+
webdown https://api.example.com/docs -s "main" -I -c -w 80 -o api_context.md
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
### From PyPI
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install webdown
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Install from Source
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Clone the repository
|
|
78
|
+
git clone https://github.com/kelp/webdown.git
|
|
79
|
+
cd webdown
|
|
80
|
+
|
|
81
|
+
# Install with pip
|
|
82
|
+
pip install .
|
|
83
|
+
|
|
84
|
+
# Or install with Poetry
|
|
85
|
+
poetry install
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Usage
|
|
89
|
+
|
|
90
|
+
Basic usage:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
webdown https://example.com/page.html -o output.md
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Output to stdout:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
webdown https://example.com/page.html
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Options
|
|
103
|
+
|
|
104
|
+
- `-o, --output`: Output file (default: stdout)
|
|
105
|
+
- `-t, --toc`: Generate table of contents
|
|
106
|
+
- `-L, --no-links`: Strip hyperlinks
|
|
107
|
+
- `-I, --no-images`: Exclude images
|
|
108
|
+
- `-s, --css SELECTOR`: CSS selector to extract specific content
|
|
109
|
+
- `-c, --compact`: Remove excessive blank lines from the output
|
|
110
|
+
- `-w, --width N`: Set the line width for wrapped text (0 for no wrapping)
|
|
111
|
+
- `-p, --progress`: Show download progress bar
|
|
112
|
+
|
|
113
|
+
**Advanced Options:**
|
|
114
|
+
|
|
115
|
+
- `--single-line-break`: Use single line breaks instead of two line breaks
|
|
116
|
+
- `--unicode`: Use Unicode characters instead of ASCII equivalents
|
|
117
|
+
- `--tables-as-html`: Keep tables as HTML instead of converting to Markdown
|
|
118
|
+
- `--emphasis-mark CHAR`: Character(s) to use for emphasis (default: '_')
|
|
119
|
+
- `--strong-mark CHARS`: Character(s) to use for strong emphasis (default: '**')
|
|
120
|
+
|
|
121
|
+
## Examples
|
|
122
|
+
|
|
123
|
+
Generate markdown with a table of contents:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
webdown https://example.com -t -o output.md
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Extract only main content:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
webdown https://example.com -s "main" -o output.md
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Strip links and images:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
webdown https://example.com -L -I -o output.md
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Compact output with progress bar and line wrapping:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
webdown https://example.com -c -p -w 80 -o output.md
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
For complete documentation, use the `--help` flag:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
webdown --help
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Documentation
|
|
154
|
+
|
|
155
|
+
API documentation is available in the [docs](https://github.com/kelp/webdown/tree/main/docs) directory.
|
|
156
|
+
|
|
157
|
+
You can generate the documentation locally with:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
make docs # Generate HTML docs in the docs/ directory
|
|
161
|
+
make docs-serve # Start a local documentation server at http://localhost:8080
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Development
|
|
165
|
+
|
|
166
|
+
### Prerequisites
|
|
167
|
+
|
|
168
|
+
- Python 3.10+ (3.13 recommended)
|
|
169
|
+
- [Poetry](https://python-poetry.org/docs/#installation) for dependency management
|
|
170
|
+
|
|
171
|
+
### Setup
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
# Clone the repository
|
|
175
|
+
git clone https://github.com/kelp/webdown.git
|
|
176
|
+
cd webdown
|
|
177
|
+
|
|
178
|
+
# Install dependencies with Poetry
|
|
179
|
+
poetry install
|
|
180
|
+
poetry run pre-commit install
|
|
181
|
+
|
|
182
|
+
# Optional: Start a Poetry shell for interactive development
|
|
183
|
+
poetry shell
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Development Commands
|
|
187
|
+
|
|
188
|
+
We use a Makefile to streamline development tasks:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# Install dependencies
|
|
192
|
+
make install
|
|
193
|
+
|
|
194
|
+
# Run tests
|
|
195
|
+
make test
|
|
196
|
+
|
|
197
|
+
# Run tests with coverage
|
|
198
|
+
make test-coverage
|
|
199
|
+
|
|
200
|
+
# Run integration tests
|
|
201
|
+
make integration-test
|
|
202
|
+
|
|
203
|
+
# Run linting
|
|
204
|
+
make lint
|
|
205
|
+
|
|
206
|
+
# Run type checking
|
|
207
|
+
make type-check
|
|
208
|
+
|
|
209
|
+
# Format code
|
|
210
|
+
make format
|
|
211
|
+
|
|
212
|
+
# Run all pre-commit hooks
|
|
213
|
+
make pre-commit
|
|
214
|
+
|
|
215
|
+
# Run all checks (lint, type-check, test)
|
|
216
|
+
make all-checks
|
|
217
|
+
|
|
218
|
+
# Build package
|
|
219
|
+
make build
|
|
220
|
+
|
|
221
|
+
# Start interactive Poetry shell
|
|
222
|
+
make shell
|
|
223
|
+
|
|
224
|
+
# Generate documentation
|
|
225
|
+
make docs
|
|
226
|
+
|
|
227
|
+
# Start documentation server
|
|
228
|
+
make docs-serve
|
|
229
|
+
|
|
230
|
+
# Publishing to PyPI (maintainers only)
|
|
231
|
+
# See CONTRIBUTING.md for details on the release process
|
|
232
|
+
make build # Build package
|
|
233
|
+
make publish-test # Publish to TestPyPI (for testing)
|
|
234
|
+
|
|
235
|
+
# Show all available commands
|
|
236
|
+
make help
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Poetry Commands
|
|
240
|
+
|
|
241
|
+
You can also use Poetry directly:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
# Start an interactive shell in the Poetry environment
|
|
245
|
+
poetry shell
|
|
246
|
+
|
|
247
|
+
# Run a command in the Poetry environment
|
|
248
|
+
poetry run pytest
|
|
249
|
+
|
|
250
|
+
# Add a new dependency
|
|
251
|
+
poetry add requests
|
|
252
|
+
|
|
253
|
+
# Add a development dependency
|
|
254
|
+
poetry add --group dev black
|
|
255
|
+
|
|
256
|
+
# Update dependencies
|
|
257
|
+
poetry update
|
|
258
|
+
|
|
259
|
+
# Build package
|
|
260
|
+
poetry build
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Python API Usage
|
|
264
|
+
|
|
265
|
+
Webdown can also be used as a Python library in your own projects:
|
|
266
|
+
|
|
267
|
+
```python
|
|
268
|
+
from webdown.converter import convert_url_to_markdown, WebdownConfig
|
|
269
|
+
|
|
270
|
+
# Method 1: Basic conversion with individual parameters
|
|
271
|
+
markdown = convert_url_to_markdown("https://example.com")
|
|
272
|
+
|
|
273
|
+
# Method 1: With all options as parameters (original style)
|
|
274
|
+
markdown = convert_url_to_markdown(
|
|
275
|
+
url="https://example.com",
|
|
276
|
+
include_links=True,
|
|
277
|
+
include_images=True,
|
|
278
|
+
include_toc=True,
|
|
279
|
+
css_selector="main", # Only extract main content
|
|
280
|
+
compact_output=True, # Remove excessive blank lines
|
|
281
|
+
body_width=80, # Wrap text at 80 characters
|
|
282
|
+
show_progress=True # Show download progress bar
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
# Method 2: Using the Config object (new in 0.3.1)
|
|
286
|
+
config = WebdownConfig(
|
|
287
|
+
# Basic options
|
|
288
|
+
url="https://example.com",
|
|
289
|
+
include_toc=True,
|
|
290
|
+
css_selector="main",
|
|
291
|
+
compact_output=True,
|
|
292
|
+
body_width=80,
|
|
293
|
+
show_progress=True,
|
|
294
|
+
|
|
295
|
+
# Advanced options (all optional)
|
|
296
|
+
single_line_break=False,
|
|
297
|
+
unicode_snob=True, # Use Unicode characters
|
|
298
|
+
tables_as_html=False,
|
|
299
|
+
emphasis_mark="_",
|
|
300
|
+
strong_mark="**"
|
|
301
|
+
)
|
|
302
|
+
markdown = convert_url_to_markdown(config)
|
|
303
|
+
|
|
304
|
+
# Save to file
|
|
305
|
+
with open("output.md", "w") as f:
|
|
306
|
+
f.write(markdown)
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Contributing
|
|
310
|
+
|
|
311
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
312
|
+
|
|
313
|
+
1. Fork the repository
|
|
314
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
315
|
+
3. Run tests to make sure everything works:
|
|
316
|
+
```bash
|
|
317
|
+
# Run standard tests
|
|
318
|
+
poetry run pytest
|
|
319
|
+
|
|
320
|
+
# Run tests with coverage
|
|
321
|
+
poetry run pytest --cov=webdown
|
|
322
|
+
|
|
323
|
+
# Run integration tests
|
|
324
|
+
poetry run pytest --integration
|
|
325
|
+
```
|
|
326
|
+
4. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
327
|
+
5. Push to the branch (`git push origin feature/amazing-feature`)
|
|
328
|
+
6. Open a Pull Request
|
|
329
|
+
|
|
330
|
+
Please make sure your code passes all tests, type checks, and follows our coding style (enforced by pre-commit hooks). We aim to maintain high code coverage (currently at 93%). When adding features, please include tests.
|
|
331
|
+
|
|
332
|
+
For more details, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
333
|
+
|
|
334
|
+
## Support
|
|
335
|
+
|
|
336
|
+
If you encounter any problems or have feature requests, please [open an issue](https://github.com/kelp/webdown/issues) on GitHub.
|
|
337
|
+
|
|
338
|
+
## License
|
|
339
|
+
|
|
340
|
+
MIT License - see the [LICENSE](LICENSE) file for details.
|
|
341
|
+
|
webdown-0.4.1/README.md
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
# Webdown
|
|
2
|
+
|
|
3
|
+
[](https://github.com/kelp/webdown/actions/workflows/python-tests.yml)
|
|
4
|
+
[](https://codecov.io/gh/kelp/webdown)
|
|
5
|
+
[](https://badge.fury.io/py/webdown)
|
|
6
|
+
[](https://pypi.org/project/webdown/)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
A Python CLI tool for converting web pages to clean, readable Markdown format. Webdown makes it easy
|
|
10
|
+
to extract content from websites for documentation, notes, content migration, or offline reading.
|
|
11
|
+
|
|
12
|
+
I made this tool specifically so I could download documentation, convert it to Markdown and feed
|
|
13
|
+
it into an LLM coding tool.
|
|
14
|
+
|
|
15
|
+
## Why Webdown?
|
|
16
|
+
|
|
17
|
+
- **Clean Conversion**: Produces readable Markdown without formatting artifacts
|
|
18
|
+
- **Selective Extraction**: Target specific page sections with CSS selectors
|
|
19
|
+
- **Customization Options**: Control links, images, text wrapping, and more
|
|
20
|
+
- **Progress Tracking**: Visual download progress for large pages with `-p` flag
|
|
21
|
+
- **Python Integration**: Use as a CLI tool or integrate into your Python projects
|
|
22
|
+
|
|
23
|
+
## Use Cases
|
|
24
|
+
|
|
25
|
+
### Documentation for AI Coding Assistants
|
|
26
|
+
|
|
27
|
+
Webdown is particularly useful for preparing documentation to use with AI-assisted coding tools like Claude Code, GitHub Copilot, or ChatGPT:
|
|
28
|
+
|
|
29
|
+
- Convert technical documentation into clean Markdown for AI context
|
|
30
|
+
- Extract only the relevant parts of large documentation pages using CSS selectors
|
|
31
|
+
- Strip out images and formatting that might consume token context
|
|
32
|
+
- Generate well-structured tables of contents for better navigation
|
|
33
|
+
- Batch process API documentation for library-specific assistance
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Example: Convert API docs and store for AI coding context
|
|
37
|
+
webdown https://api.example.com/docs -s "main" -I -c -w 80 -o api_context.md
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
### From PyPI
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install webdown
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Install from Source
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Clone the repository
|
|
52
|
+
git clone https://github.com/kelp/webdown.git
|
|
53
|
+
cd webdown
|
|
54
|
+
|
|
55
|
+
# Install with pip
|
|
56
|
+
pip install .
|
|
57
|
+
|
|
58
|
+
# Or install with Poetry
|
|
59
|
+
poetry install
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
Basic usage:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
webdown https://example.com/page.html -o output.md
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Output to stdout:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
webdown https://example.com/page.html
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Options
|
|
77
|
+
|
|
78
|
+
- `-o, --output`: Output file (default: stdout)
|
|
79
|
+
- `-t, --toc`: Generate table of contents
|
|
80
|
+
- `-L, --no-links`: Strip hyperlinks
|
|
81
|
+
- `-I, --no-images`: Exclude images
|
|
82
|
+
- `-s, --css SELECTOR`: CSS selector to extract specific content
|
|
83
|
+
- `-c, --compact`: Remove excessive blank lines from the output
|
|
84
|
+
- `-w, --width N`: Set the line width for wrapped text (0 for no wrapping)
|
|
85
|
+
- `-p, --progress`: Show download progress bar
|
|
86
|
+
|
|
87
|
+
**Advanced Options:**
|
|
88
|
+
|
|
89
|
+
- `--single-line-break`: Use single line breaks instead of two line breaks
|
|
90
|
+
- `--unicode`: Use Unicode characters instead of ASCII equivalents
|
|
91
|
+
- `--tables-as-html`: Keep tables as HTML instead of converting to Markdown
|
|
92
|
+
- `--emphasis-mark CHAR`: Character(s) to use for emphasis (default: '_')
|
|
93
|
+
- `--strong-mark CHARS`: Character(s) to use for strong emphasis (default: '**')
|
|
94
|
+
|
|
95
|
+
## Examples
|
|
96
|
+
|
|
97
|
+
Generate markdown with a table of contents:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
webdown https://example.com -t -o output.md
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Extract only main content:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
webdown https://example.com -s "main" -o output.md
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Strip links and images:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
webdown https://example.com -L -I -o output.md
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Compact output with progress bar and line wrapping:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
webdown https://example.com -c -p -w 80 -o output.md
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
For complete documentation, use the `--help` flag:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
webdown --help
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Documentation
|
|
128
|
+
|
|
129
|
+
API documentation is available in the [docs](https://github.com/kelp/webdown/tree/main/docs) directory.
|
|
130
|
+
|
|
131
|
+
You can generate the documentation locally with:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
make docs # Generate HTML docs in the docs/ directory
|
|
135
|
+
make docs-serve # Start a local documentation server at http://localhost:8080
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Development
|
|
139
|
+
|
|
140
|
+
### Prerequisites
|
|
141
|
+
|
|
142
|
+
- Python 3.10+ (3.13 recommended)
|
|
143
|
+
- [Poetry](https://python-poetry.org/docs/#installation) for dependency management
|
|
144
|
+
|
|
145
|
+
### Setup
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Clone the repository
|
|
149
|
+
git clone https://github.com/kelp/webdown.git
|
|
150
|
+
cd webdown
|
|
151
|
+
|
|
152
|
+
# Install dependencies with Poetry
|
|
153
|
+
poetry install
|
|
154
|
+
poetry run pre-commit install
|
|
155
|
+
|
|
156
|
+
# Optional: Start a Poetry shell for interactive development
|
|
157
|
+
poetry shell
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Development Commands
|
|
161
|
+
|
|
162
|
+
We use a Makefile to streamline development tasks:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Install dependencies
|
|
166
|
+
make install
|
|
167
|
+
|
|
168
|
+
# Run tests
|
|
169
|
+
make test
|
|
170
|
+
|
|
171
|
+
# Run tests with coverage
|
|
172
|
+
make test-coverage
|
|
173
|
+
|
|
174
|
+
# Run integration tests
|
|
175
|
+
make integration-test
|
|
176
|
+
|
|
177
|
+
# Run linting
|
|
178
|
+
make lint
|
|
179
|
+
|
|
180
|
+
# Run type checking
|
|
181
|
+
make type-check
|
|
182
|
+
|
|
183
|
+
# Format code
|
|
184
|
+
make format
|
|
185
|
+
|
|
186
|
+
# Run all pre-commit hooks
|
|
187
|
+
make pre-commit
|
|
188
|
+
|
|
189
|
+
# Run all checks (lint, type-check, test)
|
|
190
|
+
make all-checks
|
|
191
|
+
|
|
192
|
+
# Build package
|
|
193
|
+
make build
|
|
194
|
+
|
|
195
|
+
# Start interactive Poetry shell
|
|
196
|
+
make shell
|
|
197
|
+
|
|
198
|
+
# Generate documentation
|
|
199
|
+
make docs
|
|
200
|
+
|
|
201
|
+
# Start documentation server
|
|
202
|
+
make docs-serve
|
|
203
|
+
|
|
204
|
+
# Publishing to PyPI (maintainers only)
|
|
205
|
+
# See CONTRIBUTING.md for details on the release process
|
|
206
|
+
make build # Build package
|
|
207
|
+
make publish-test # Publish to TestPyPI (for testing)
|
|
208
|
+
|
|
209
|
+
# Show all available commands
|
|
210
|
+
make help
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Poetry Commands
|
|
214
|
+
|
|
215
|
+
You can also use Poetry directly:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Start an interactive shell in the Poetry environment
|
|
219
|
+
poetry shell
|
|
220
|
+
|
|
221
|
+
# Run a command in the Poetry environment
|
|
222
|
+
poetry run pytest
|
|
223
|
+
|
|
224
|
+
# Add a new dependency
|
|
225
|
+
poetry add requests
|
|
226
|
+
|
|
227
|
+
# Add a development dependency
|
|
228
|
+
poetry add --group dev black
|
|
229
|
+
|
|
230
|
+
# Update dependencies
|
|
231
|
+
poetry update
|
|
232
|
+
|
|
233
|
+
# Build package
|
|
234
|
+
poetry build
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Python API Usage
|
|
238
|
+
|
|
239
|
+
Webdown can also be used as a Python library in your own projects:
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
from webdown.converter import convert_url_to_markdown, WebdownConfig
|
|
243
|
+
|
|
244
|
+
# Method 1: Basic conversion with individual parameters
|
|
245
|
+
markdown = convert_url_to_markdown("https://example.com")
|
|
246
|
+
|
|
247
|
+
# Method 1: With all options as parameters (original style)
|
|
248
|
+
markdown = convert_url_to_markdown(
|
|
249
|
+
url="https://example.com",
|
|
250
|
+
include_links=True,
|
|
251
|
+
include_images=True,
|
|
252
|
+
include_toc=True,
|
|
253
|
+
css_selector="main", # Only extract main content
|
|
254
|
+
compact_output=True, # Remove excessive blank lines
|
|
255
|
+
body_width=80, # Wrap text at 80 characters
|
|
256
|
+
show_progress=True # Show download progress bar
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
# Method 2: Using the Config object (new in 0.3.1)
|
|
260
|
+
config = WebdownConfig(
|
|
261
|
+
# Basic options
|
|
262
|
+
url="https://example.com",
|
|
263
|
+
include_toc=True,
|
|
264
|
+
css_selector="main",
|
|
265
|
+
compact_output=True,
|
|
266
|
+
body_width=80,
|
|
267
|
+
show_progress=True,
|
|
268
|
+
|
|
269
|
+
# Advanced options (all optional)
|
|
270
|
+
single_line_break=False,
|
|
271
|
+
unicode_snob=True, # Use Unicode characters
|
|
272
|
+
tables_as_html=False,
|
|
273
|
+
emphasis_mark="_",
|
|
274
|
+
strong_mark="**"
|
|
275
|
+
)
|
|
276
|
+
markdown = convert_url_to_markdown(config)
|
|
277
|
+
|
|
278
|
+
# Save to file
|
|
279
|
+
with open("output.md", "w") as f:
|
|
280
|
+
f.write(markdown)
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
## Contributing
|
|
284
|
+
|
|
285
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
286
|
+
|
|
287
|
+
1. Fork the repository
|
|
288
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
289
|
+
3. Run tests to make sure everything works:
|
|
290
|
+
```bash
|
|
291
|
+
# Run standard tests
|
|
292
|
+
poetry run pytest
|
|
293
|
+
|
|
294
|
+
# Run tests with coverage
|
|
295
|
+
poetry run pytest --cov=webdown
|
|
296
|
+
|
|
297
|
+
# Run integration tests
|
|
298
|
+
poetry run pytest --integration
|
|
299
|
+
```
|
|
300
|
+
4. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
301
|
+
5. Push to the branch (`git push origin feature/amazing-feature`)
|
|
302
|
+
6. Open a Pull Request
|
|
303
|
+
|
|
304
|
+
Please make sure your code passes all tests, type checks, and follows our coding style (enforced by pre-commit hooks). We aim to maintain high code coverage (currently at 93%). When adding features, please include tests.
|
|
305
|
+
|
|
306
|
+
For more details, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
307
|
+
|
|
308
|
+
## Support
|
|
309
|
+
|
|
310
|
+
If you encounter any problems or have feature requests, please [open an issue](https://github.com/kelp/webdown/issues) on GitHub.
|
|
311
|
+
|
|
312
|
+
## License
|
|
313
|
+
|
|
314
|
+
MIT License - see the [LICENSE](LICENSE) file for details.
|