Turn any web article into a clean EPUB for your e-ink reader. Also a website that uses the CLI tool on the backend to convert URLs to EPUB https://rekopub.monoexp.com
|
|
8 órája | |
|---|---|---|
| cmd | 8 órája | |
| deploy | 8 órája | |
| internal | 8 órája | |
| pull-releases | 8 órája | |
| site | 8 órája | |
| testdata | 1 napja | |
| .gitattributes | 1 napja | |
| .gitignore | 8 órája | |
| LICENSE | 1 napja | |
| PLAN.md | 1 napja | |
| README.md | 8 órája | |
| VERSION | 8 órája | |
| build.cmd | 1 napja | |
| go.mod | 1 napja | |
| go.sum | 1 napja | |
| test-examples.cmd | 1 napja |
Turn any web article into a clean EPUB for your e-ink reader.
rekopub is a small command-line tool written in Go. You give it a URL. It downloads the page, keeps the article itself (dropping navigation, ads, pop-ups and comments) and writes an EPUB tuned for grayscale e-ink screens. It is built for the reMarkable 2 and the Kobo Clara HD.
rekopub -URL https://example.com/some-article -SAVE ~/Books/
You can also paste an address into the form on rekopub.monoexp.com, which runs ReKoPub on the server and gives you download links.
-KEPUB writes a .kepub.epub file, which Kobo opens with its faster renderer and shows reading stats for.-FORCE.Download the latest version for your computer from rekopub.monoexp.com:
| Computer | File |
|---|---|
| Windows (most PCs) | rekopub_windows_amd64.zip |
| Windows on Arm (e.g. Snapdragon laptops) | rekopub_windows_arm64.zip |
| Mac with Apple silicon (M1 and later) | rekopub_darwin_arm64.tar.gz |
| Mac with Intel | rekopub_darwin_amd64.tar.gz |
| Linux | rekopub_linux_amd64.tar.gz (or _arm64) |
Unpack it and put rekopub (rekopub.exe on Windows) somewhere convenient. There's nothing to install and nothing else to download. It's a command-line program, so run it from Command Prompt, PowerShell or Terminal rather than by double-clicking. The site shows the version and the commit it was built from; checksums.txt lets you check the download.
The binaries aren't code-signed, so the first run may show a warning:
xattr -d com.apple.quarantine rekopub once, in the folder where you unpacked it.go install git.monoexp.com/bajdev/rekopub/cmd/rekopub@latest
The binary is installed into $(go env GOPATH)/bin. Make sure that folder is on your PATH.
git clone https://git.monoexp.com/bajdev/ReKoPub.git
cd ReKoPub
go build -o rekopub ./cmd/rekopub
Install Go 1.26 or newer, then run build.cmd from the repository folder:
git clone https://git.monoexp.com/bajdev/ReKoPub.git
cd ReKoPub
build.cmd
In PowerShell, run .\build.cmd instead. The script builds rekopub.exe in the repository folder, whichever folder you start it from. To update, run git pull, then build.cmd again.
To try it on real articles, run test-examples.cmd (.\test-examples.cmd in PowerShell). It rebuilds rekopub.exe, converts a handful of sample articles into test-examples\, replacing books from earlier runs, and prints how many succeeded. Run test-examples.cmd kepub to make Kobo KEPUBs (.kepub.epub) instead. Edit the list of URLs in the script to test other pages.
rekopub -URL <url> -SAVE <path> [-FORCE] [-KEPUB] [-LOCAL]
rekopub -VERSION
| Flag | Required | Description |
|---|---|---|
-URL |
yes | The web page to convert. Must start with http:// or https://. |
-SAVE |
yes | Where to write the book: a file or a folder (see below). Missing folders are created. |
-FORCE |
no | Overwrite the output file if it already exists. |
-KEPUB |
no | Write a Kobo KEPUB (.kepub.epub) instead of a plain EPUB. |
-LOCAL |
no | Allow -URL to be on your own computer or a private network, such as a wiki at home. Without it, local and private addresses are refused. |
-VERSION |
no | Print the version and exit. Include it when reporting a problem. |
Flag names are case-sensitive: -URL works, -url does not.
-SAVE is interpreted-SAVE value |
Result |
|---|---|
Ends in /, e.g. ~/Books/ |
A folder (created if missing). The filename comes from the article title: ~/Books/<article-title>.epub |
An existing folder, e.g. ~/Books |
Same as above |
Ends in .epub, e.g. ~/Books/a.epub |
Written to exactly that file |
Anything else, e.g. ~/Books/a |
Treated as a file name, and .epub is appended: ~/Books/a.epub |
Watch the trailing slash when the folder doesn't exist yet. -SAVE ~/Books/new/ creates a folder called new, while -SAVE ~/Books/new writes a file called new.epub.
ReKoPub never replaces an existing file unless you ask it to:
$ rekopub -URL https://example.com/a -SAVE ~/Books/a.epub
error: /home/me/Books/a.epub already exists (use -FORCE to overwrite)
$ rekopub -URL https://example.com/a -SAVE ~/Books/a.epub -FORCE
/home/me/Books/a.epub
When the output path is known up front, this check happens before anything is downloaded. With -FORCE, the old file stays intact until the new one has been fully written.
-KEPUB)Kobo only uses its faster renderer for files ending in .kepub.epub, so -KEPUB adjusts the extension for you:
-SAVE value |
Saved as |
|---|---|
~/Books/ (folder) |
~/Books/<article-title>.kepub.epub |
~/Books/a.kepub.epub |
~/Books/a.kepub.epub |
~/Books/a.epub |
~/Books/a.kepub.epub (with a note on stderr) |
~/Books/a |
~/Books/a.kepub.epub |
Passing a .kepub.epub path without -KEPUB is an error, because a plain EPUB with that name would display badly on a Kobo.
Use -KEPUB for the best experience: faster page turns, time-left statistics and more reliable highlights.
Save straight to it:
# Linux
rekopub -URL https://example.com/article -SAVE /media/$USER/KOBOeReader/Articles/ -KEPUB
# macOS
rekopub -URL https://example.com/article -SAVE /Volumes/KOBOeReader/Articles/ -KEPUB
# Windows (the drive letter may differ)
rekopub.exe -URL https://example.com/article -SAVE E:\Articles\ -KEPUB
Eject the Kobo. The article appears in your library.
A plain EPUB (without -KEPUB) also works on the Kobo, but it opens in Kobo's older renderer.
Use plain EPUB, without -KEPUB.
Save the book locally:
rekopub -URL https://example.com/article -SAVE ~/reMarkable/
Upload it with any of these:
| Code | Meaning |
|---|---|
0 |
Success |
1 |
The page couldn't be fetched (network error, non-200 response, not an HTML page) |
2 |
Invalid arguments, including a local or private -URL without -LOCAL |
3 |
No readable article content was found on the page |
4 |
The book couldn't be built or written (including folder creation) |
5 |
The output file already exists and -FORCE was not given |
130 |
Stopped with Ctrl-C |
Example in a script:
while read -r url; do
rekopub -URL "$url" -SAVE ~/Books/ || echo "failed: $url" >&2
done < urls.txt
| Message | What it means |
|---|---|
can't find the server … |
The address is mistyped, or the computer is offline. |
… refused the connection / … took too long to respond |
The site is down or very slow. Try again later. |
… security certificate isn't valid |
The connection can't be trusted, so ReKoPub won't use it. Check the address; on a work or school network, a proxy may be intercepting secure connections. |
… returned 403 Forbidden; the site may need a login or may block automated downloads |
The site refused the request. Some sites block anything that isn't a full web browser. |
… returned 404 Not Found; check the address |
The page doesn't exist at that address. |
no readable article content found |
The page has no article text ReKoPub can find. Usually the page builds its content with JavaScript, or it's a paywall or cookie wall. |
warning: image … skipped: … |
One image couldn't be downloaded or read. The book is still made, with the image's description in its place. |
warning: cover image … skipped, using a plain cover |
The page's preview image couldn't be used, so the book gets a typographic cover instead. |
-URL … is on this computer or a private network; add -LOCAL to convert it |
Local and private addresses are refused unless you add -LOCAL (see Privacy and security). |
… is a local or private address … |
The page tried to send ReKoPub to your own computer or network, through a redirect or an image. That's refused for pages on the internet, with or without -LOCAL. To convert a page on your own network, give its local address as -URL and add -LOCAL. |
To report a problem with a particular page, include the output of rekopub -VERSION, the full command, everything it printed, and a saved copy of the page:
curl -L -A "Mozilla/5.0" -o page.html "https://example.com/the-article"
(On Windows, use curl.exe, which comes with Windows 10 and 11.)
-URL, its images and its preview image, over http:// or https:// only. It never reads files on your computer: file: links and local paths in a page are ignored, and the only file it writes is the book.localhost), your home or office network (such as 192.168.x.x or 10.x.x.x) and similar private addresses. To convert a page there, such as a wiki on your network, add -LOCAL; that page's local images are then allowed too. A web page chooses where its images come from, and can redirect, so pages on the internet can never make ReKoPub connect to those addresses, with or without -LOCAL. With a proxy set in HTTP_PROXY or HTTPS_PROXY, the proxy makes the connections, so ReKoPub can't check them. The website converter never uses -LOCAL.-FORCE. Filenames made from article titles contain only letters, digits and dashes, so a title can't place the book outside the folder you chose.3.colspan/rowspan) may come out with uneven rows, because the extraction library drops those attributes.ReKoPub is meant for saving articles for your own offline reading. Every book records its source URL on the first page and in its metadata.
go test ./... # unit and end-to-end tests
go test -race ./... # with the race detector
go vet ./... && staticcheck ./...
The tests also check the generated books with epubcheck, which needs Java. Set EPUBCHECK_JAR to the path of epubcheck.jar to turn those checks on; without it they're skipped. Run them before every release.
On Windows, build.cmd builds rekopub.exe and test-examples.cmd converts a set of real articles into test-examples\ for checking on the devices (see From source on Windows).
cmd/rekopub/ CLI entry point (flags, exit codes, -VERSION)
cmd/rekopub-web/ The website's converter server (settings from the environment)
internal/web/ Converter: form checks, limits, running rekopub, serving and deleting books
internal/pipeline/ Runs the stages below in order
internal/fetch/ HTTP download, local-network guard, character-set decoding, friendly network errors
internal/extract/ Article and metadata extraction (go-trafilatura, page metadata)
internal/clean/ Pre-extraction fixes, sanitising, XHTML conversion
internal/assets/ Image download and e-ink processing
internal/cover/ Cover drawing
internal/device/ e-ink device profile (image and cover sizes, gray levels)
internal/build/ EPUB packaging (go-epub), stylesheet, contents and metadata
internal/kepub/ KEPUB conversion (kepubify)
internal/save/ Output path rules, folder creation, -FORCE, atomic writes
internal/epubtest/ Test helpers for checking generated books
testdata/ Saved HTML pages and images used by the tests
site/ rekopub.monoexp.com (published on every merge into main)
deploy/ nginx site file and example settings for the server
VERSION The version release builds report
Every merge into main builds and publishes rekopub.monoexp.com: the server's deploy pipeline (bajdev/devops, kind cli) builds ./cmd/rekopub for Windows, macOS and Linux on amd64 and arm64, archives each binary with README.md and LICENSE, writes checksums.txt, and publishes them in download/ alongside the website in site/. It also builds the converter (./cmd/rekopub-web) and a rekopub for the server into /opt/apps/rekopub-web/, and restarts it before publishing the site. The page shows the version, the build date and the commit, which the pipeline fills in where site/index.html has @VERSION@, @DATE@, @COMMIT@ and @SHORT@.
The version comes from VERSION (1.2.3, without the v). To release a new version, change it in the pull request. After the merge, tag the merge commit:
git tag -a v1.2.3 -m "v1.2.3"
git push origin v1.2.3
Merges that don't change VERSION still republish the site and rebuild the binaries, with the same version and the new commit. Release binaries include the Go standard library, so run govulncheck (go run golang.org/x/vuln/cmd/govulncheck@latest ./...) now and then; when it finds something, update Go or the dependency and merge.
To preview the site, open site/index.html in a browser; the placeholders show as they are. The converter form needs the server below.
The form on the site sends the address and format to rekopub-web, which runs as goapp@rekopub-web on 127.0.0.1:8004 behind nginx (deploy/rekopub.monoexp.com.conf passes it /api/ and /books/). For each conversion it:
http:// or https://, standard ports, no user name or password, not a local or private address;rekopub, never with -LOCAL (with -KEPUB for KEPUB, both for "Both") as a separate process with a 2-minute time limit and an empty environment, saving into a new folder with a random 128-bit name in data/books/;/books/<folder>/<file>. Books are deleted 24 hours later.Settings come from /etc/goapps/rekopub-web.env (see deploy/rekopub-web.env.example and cmd/rekopub-web/main.go). To run it locally, next to a built rekopub:
go build -o /tmp/rk/ ./cmd/rekopub ./cmd/rekopub-web
cd /tmp/rk && PORT=18014 ./rekopub-web
curl -H 'Accept: application/json' -d url=https://example.com/ -d format=epub http://127.0.0.1:18014/api/convert
Without Accept: application/json it answers with an HTML page, which is what browsers without JavaScript get.
See PLAN.md for the full design.
| Milestone | Scope | Status |
|---|---|---|
| M0 | Project setup, flag handling, saving rules (-SAVE, -FORCE, folders) |
Done |
| M1 | Basic working version: text-only EPUB | Done |
| M2 | Clean XHTML and the e-ink stylesheet | Done |
| M3 | Images processed for e-ink | Done |
| M4 | Metadata, cover and table of contents | Done |
| M5 | -KEPUB for Kobo |
Done |
| M6 | Polish and v1 release | Done |
| M7 | Several URLs in one book: repeat -URL, or list them in a file with -URLS; optional -TITLE |
Planned |
Possible later features: JavaScript rendering, author and cover overrides, and profiles for colour e-ink devices.
ReKoPub builds on these open-source projects:
ReKoPub is released under the MIT License.