| Crates.io | twars-url2md |
| lib.rs | twars-url2md |
| version | 1.4.2 |
| created_at | 2025-02-03 18:57:27.29556+00 |
| updated_at | 2025-04-07 17:21:53.600194+00 |
| description | A powerful CLI tool that fetches web pages and converts them to clean Markdown format using Monolith for content extraction and htmd for conversion |
| homepage | https://github.com/twardoch/twars-url2md |
| repository | https://github.com/twardoch/twars-url2md |
| max_upload_size | |
| id | 1540902 |
| size | 145,111 |
twars-url2md is a fast and robust command-line tool written in Rust that fetches web pages, cleans up their HTML content, and converts them into clean Markdown.
You can drop a text that contains URLs onto the app, and it will find all the URLs and save Markdown versions of the pages in a logical folder structure. The output is not perfect, but the tool is fast and robust.
The easiest way to get started is to download the pre-compiled binary for your platform.
twars-url2md-macos-universal.tar.gz (works on both Intel and Apple Silicon)twars-url2md-windows-x86_64.exe.ziptwars-url2md-linux-x86_64.tar.gztar -xzf twars-url2md-*.tar.gzchmod +x twars-url2mdsudo mv twars-url2md /usr/local/bin/ or mv twars-url2md ~/.local/bin/If you have Rust installed (version 1.70.0 or later), you can install directly from crates.io:
cargo install twars-url2md
For the latest version or to customize the build:
# Clone the repository
git clone https://github.com/twardoch/twars-url2md.git
cd twars-url2md
# Build and install
cargo build --release
mv target/release/twars-url2md /usr/local/bin/ # or any location in your PATH
Usage: twars-url2md [OPTIONS]
Options:
-i, --input <FILE> Input file containing URLs or local file paths (one per line)
-o, --output <DIR> Output directory for markdown files
--stdin Read URLs from standard input
--base-url <URL> Base URL for resolving relative links
-p, --pack <FILE> Output file to pack all markdown files together
-v, --verbose Enable verbose output
-h, --help Print help
-V, --version Print version
The tool accepts URLs and local file paths from:
--input--stdin--input or --stdin must be specified--output <DIR>: Create individual Markdown files in this directory--pack <FILE>: Combine all Markdown files into a single output fileYou can now include local HTML files in your input:
/path/to/file.htmlfile:///path/to/file.html# Process a single URL and print to stdout
echo "https://example.com" | twars-url2md --stdin
# Process URLs from a file with specific output directory
twars-url2md --input urls.txt --output ./markdown_output
# Process piped URLs with base URL for relative links
cat urls.txt | twars-url2md --stdin --base-url "https://example.com" --output ./output
# Show verbose output
twars-url2md --input urls.txt --output ./output --verbose
# Process URLs and create a combined Markdown file
twars-url2md --input urls.txt --pack combined.md
# Both individual files and a combined file
twars-url2md --input urls.txt --output ./output --pack combined.md
# Create a test HTML file
echo "<html><body><h1>Test</h1><p>Content</p></body></html>" > test.html
# Process a local HTML file
echo "$PWD/test.html" > local_paths.txt
twars-url2md --input local_paths.txt --output ./output
# Mix local and remote content
cat > mixed.txt << EOF
https://example.com
file://$PWD/test.html
EOF
twars-url2md --input mixed.txt --pack combined.md
# Extract and process links from a webpage
curl "https://en.wikipedia.org/wiki/Rust_(programming_language)" | twars-url2md --stdin --output rust_wiki/
# Process multiple files
find ./html_files -name "*.html" > files_to_process.txt
twars-url2md --input files_to_process.txt --output ./markdown_output --pack all_content.md
The tool organizes output into a directory structure based on the URLs:
output/
├── example.com/
│ ├── index.md # from https://example.com/
│ └── articles/
│ └── page.md # from https://example.com/articles/page
└── another-site.com/
└── post/
└── article.md # from https://another-site.com/post/article
For local files, the directory structure mirrors the file path.
# Run all tests
cargo test
# Run with specific features
cargo test --all-features
# Run specific test
cargo test test_name
cargo fmtcargo clippy --all-targets --all-featuresTo publish a new release of twars-url2md:
# Update version in Cargo.toml (e.g. from 1.3.6 to 1.3.7)
# Ensure everything works
cargo test
cargo clippy --all-targets --all-features
cargo fmt --check
# Build in release mode
cargo build --release
# Test the binary
./target/release/twars-url2md --help
# Login to crates.io (if not already logged in)
cargo login
# Verify the package
cargo package
# Publish
cargo publish
# Create and push a tag matching your version
git tag -a v1.3.7 -m "Release v1.3.7"
git push origin v1.3.7
The configured GitHub Actions workflow (.github/workflows/ci.yml) will automatically:
If GitHub Actions fails, you can create the release manually:
# macOS universal binary
cargo build --release --target x86_64-apple-darwin
cargo build --release --target aarch64-apple-darwin
lipo "target/x86_64-apple-darwin/release/twars-url2md" "target/aarch64-apple-darwin/release/twars-url2md" -create -output "target/twars-url2md"
tar czf twars-url2md-macos-universal.tar.gz -C target twars-url2md
# Linux
cargo build --release --target x86_64-unknown-linux-gnu
tar czf twars-url2md-linux-x86_64.tar.gz -C target/x86_64-unknown-linux-gnu/release twars-url2md
# Windows
cargo build --release --target x86_64-pc-windows-msvc
cd target/x86_64-pc-windows-msvc/release
7z a ../../../twars-url2md-windows-x86_64.zip twars-url2md.exe
cargo install twars-url2mdMIT License - see LICENSE for details.
Adam Twardoch (@twardoch)
For bug reports, feature requests, or general questions, please open an issue on the GitHub repository.